Skip to content

Commit 9a5d8c9

Browse files
CBL-Mariner-Botarchana25-msKanishk-Bansal
authored
Merge PR "[AUTO-CHERRYPICK] [CRITICAL] Patch ncurses for CVE-2025-69720 - branch 3.0-dev" #16337
Co-authored-by: Archana Shettigar <v-shettigara@microsoft.com> Co-authored-by: Kanishk Bansal <103916909+Kanishk-Bansal@users.noreply.github.com>
1 parent 9c9f61c commit 9a5d8c9

6 files changed

Lines changed: 171 additions & 23 deletions

File tree

SPECS/ncurses/CVE-2025-69720.patch

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
From 3f157eac006b4c80b17e43d3c9d776b3f05c01d8 Mon Sep 17 00:00:00 2001
2+
From: Archana Shettigar <v-shettigara@microsoft.com>
3+
Date: Wed, 25 Mar 2026 10:04:19 +0530
4+
Subject: [PATCH] Address CVE-2025-69720
5+
6+
Upstream Patch Reference: https://invisible-island.net/archives/ncurses/6.5/ncurses-6.5-20251213.patch.gz
7+
---
8+
include/nc_win32.h | 8 +++++++-
9+
ncurses/tinfo/comp_parse.c | 20 ++++++++++++++++++
10+
progs/infocmp.c | 5 +++--
11+
progs/tic.c | 5 ++---
12+
test/railroad.c | 2 +-
13+
5 files changed, 33 insertions(+), 7 deletions(-)
14+
15+
diff --git a/include/nc_win32.h b/include/nc_win32.h
16+
index e67b8e0..c0b3882 100644
17+
--- a/include/nc_win32.h
18+
+++ b/include/nc_win32.h
19+
@@ -111,8 +111,14 @@ extern NCURSES_EXPORT(int) _nc_console_vt_supported(void);
20+
extern NCURSES_EXPORT(int) _nc_console_checkmintty(int fd, LPHANDLE pMinTTY);
21+
#endif
22+
23+
-#undef VALID_TERM_ENV
24+
+/*
25+
+ * Allow for build-override, e.g., MinGW used "cygwin".
26+
+ */
27+
+#ifndef MS_TERMINAL
28+
#define MS_TERMINAL "ms-terminal"
29+
+#endif
30+
+
31+
+#undef VALID_TERM_ENV
32+
#define VALID_TERM_ENV(term_env, no_terminal) \
33+
(term_env = (NonEmpty(term_env) \
34+
? term_env \
35+
diff --git a/ncurses/tinfo/comp_parse.c b/ncurses/tinfo/comp_parse.c
36+
index 4244df4..21e28a8 100644
37+
--- a/ncurses/tinfo/comp_parse.c
38+
+++ b/ncurses/tinfo/comp_parse.c
39+
@@ -539,8 +539,12 @@ _nc_resolve_uses2(bool fullresolve, bool literal)
40+
if (fullresolve) {
41+
do {
42+
ENTRY merged;
43+
+ bool progress;
44+
+ bool attempts;
45+
46+
keepgoing = FALSE;
47+
+ progress = FALSE;
48+
+ attempts = FALSE;
49+
50+
for_entry_list(qp) {
51+
if (qp->nuses > 0) {
52+
@@ -599,6 +601,7 @@ _nc_resolve_uses2(bool fullresolve, bool literal)
53+
#endif
54+
qp->tterm = merged.tterm;
55+
_nc_wrap_entry(qp, TRUE);
56+
+ progress = TRUE;
57+
58+
/*
59+
* We know every entry is resolvable because name resolution
60+
@@ -609,6 +612,21 @@ _nc_resolve_uses2(bool fullresolve, bool literal)
61+
keepgoing = TRUE;
62+
}
63+
}
64+
+ /*
65+
+ * If we went all the way through the list without making any
66+
+ * changes, while there were remaining use-linkages, something went
67+
+ * wrong. Give up.
68+
+ */
69+
+ if (!progress && attempts) {
70+
+ for_entry_list(qp) {
71+
+ for (i = 0; i < qp->nuses; ++i) {
72+
+ _nc_warning("problem with use=%s", qp->uses[i].name);
73+
+ }
74+
+ }
75+
+ _nc_warning("merge failed, infinite loop");
76+
+ DEBUG(2, (T_RETURN("false")));
77+
+ return FALSE;
78+
+ }
79+
} while
80+
(keepgoing);
81+
82+
diff --git a/progs/infocmp.c b/progs/infocmp.c
83+
index 8178455..260769f 100644
84+
--- a/progs/infocmp.c
85+
+++ b/progs/infocmp.c
86+
@@ -823,7 +823,7 @@ lookup_params(const assoc * table, char *dst, char *src)
87+
static void
88+
analyze_string(const char *name, const char *cap, TERMTYPE2 *tp)
89+
{
90+
- char buf2[MAX_TERMINFO_LENGTH];
91+
+ char buf2[MAX_TERMINFO_LENGTH + 1];
92+
const char *sp;
93+
const assoc *ap;
94+
int tp_lines = tp->Numbers[2];
95+
@@ -853,7 +853,8 @@ analyze_string(const char *name, const char *cap, TERMTYPE2 *tp)
96+
if (VALID_STRING(cp) &&
97+
cp[0] != '\0' &&
98+
cp != cap) {
99+
- len = strlen(cp);
100+
+ if ((len = strlen(cp)) > MAX_TERMINFO_LENGTH)
101+
+ len = MAX_TERMINFO_LENGTH;
102+
_nc_STRNCPY(buf2, sp, len);
103+
buf2[len] = '\0';
104+
105+
diff --git a/progs/tic.c b/progs/tic.c
106+
index ae65e63..4e4ae4c 100644
107+
--- a/progs/tic.c
108+
+++ b/progs/tic.c
109+
@@ -3274,9 +3274,9 @@ check_termtype(TERMTYPE2 *tp, bool literal)
110+
111+
_nc_tparm_err = 0;
112+
if (PRESENT(exit_attribute_mode)) {
113+
- zero = strdup(CHECK_SGR(0, exit_attribute_mode));
114+
+ zero = CHECK_SGR(0, exit_attribute_mode);
115+
} else {
116+
- zero = strdup(TIPARM_9(set_attributes, 0, 0, 0, 0, 0, 0, 0, 0, 0));
117+
+ zero = TIPARM_9(set_attributes, 0, 0, 0, 0, 0, 0, 0, 0, 0);
118+
}
119+
check_tparm_err(0);
120+
121+
@@ -3290,7 +3290,6 @@ check_termtype(TERMTYPE2 *tp, bool literal)
122+
CHECK_SGR(7, enter_secure_mode);
123+
CHECK_SGR(8, enter_protected_mode);
124+
CHECK_SGR(9, enter_alt_charset_mode);
125+
- free(zero);
126+
} else {
127+
_nc_warning("sgr(0) did not return a value");
128+
}
129+
diff --git a/test/railroad.c b/test/railroad.c
130+
index 4d7c070..10fccd2 100644
131+
--- a/test/railroad.c
132+
+++ b/test/railroad.c
133+
@@ -192,7 +192,7 @@ railroad(char **args)
134+
135+
if (name == 0)
136+
#ifdef EXP_WIN32_DRIVER
137+
- name = "ms-terminal";
138+
+ name = MS_TERMINAL;
139+
#else
140+
name = "dumb";
141+
#endif
142+
--
143+
2.45.4
144+

SPECS/ncurses/ncurses.spec

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Summary: Libraries for terminal handling of character screens
44
Name: ncurses
55
Version: 6.4
6-
Release: 2%{?dist}
6+
Release: 3%{?dist}
77
License: MIT
88
Vendor: Microsoft Corporation
99
Distribution: Azure Linux
@@ -34,6 +34,7 @@ URL: https://invisible-island.net/ncurses/
3434
# Use a nopatch file to clear the CVE after choosing the correct patch level
3535
#
3636
Source0: https://invisible-mirror.net/archives/%{name}/current/%{name}-%{version}-%{patchlevel}.tgz
37+
Patch0: CVE-2025-69720.patch
3738
Requires: %{name}-libs = %{version}-%{release}
3839

3940

@@ -234,6 +235,9 @@ xz NEWS
234235
%files term -f terms.term
235236

236237
%changelog
238+
* Wed Mar 25 2026 Archana Shettigar <v-shettigara@microsoft.com> - 6.4-3
239+
- Patch CVE-2025-69720
240+
237241
* Tue Nov 28 2023 Andrew Phelps <anphel@microsoft.com> - 6.4-2
238242
- Update to version 6.4-20231125
239243

toolkit/resources/manifests/package/pkggen_core_aarch64.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ libpkgconf-2.0.2-1.azl3.aarch64.rpm
3434
pkgconf-2.0.2-1.azl3.aarch64.rpm
3535
pkgconf-m4-2.0.2-1.azl3.noarch.rpm
3636
pkgconf-pkg-config-2.0.2-1.azl3.aarch64.rpm
37-
ncurses-6.4-2.azl3.aarch64.rpm
38-
ncurses-compat-6.4-2.azl3.aarch64.rpm
39-
ncurses-devel-6.4-2.azl3.aarch64.rpm
40-
ncurses-libs-6.4-2.azl3.aarch64.rpm
41-
ncurses-term-6.4-2.azl3.aarch64.rpm
37+
ncurses-6.4-3.azl3.aarch64.rpm
38+
ncurses-compat-6.4-3.azl3.aarch64.rpm
39+
ncurses-devel-6.4-3.azl3.aarch64.rpm
40+
ncurses-libs-6.4-3.azl3.aarch64.rpm
41+
ncurses-term-6.4-3.azl3.aarch64.rpm
4242
readline-8.2-2.azl3.aarch64.rpm
4343
readline-devel-8.2-2.azl3.aarch64.rpm
4444
libattr-2.5.2-1.azl3.aarch64.rpm

toolkit/resources/manifests/package/pkggen_core_x86_64.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ libpkgconf-2.0.2-1.azl3.x86_64.rpm
3434
pkgconf-2.0.2-1.azl3.x86_64.rpm
3535
pkgconf-m4-2.0.2-1.azl3.noarch.rpm
3636
pkgconf-pkg-config-2.0.2-1.azl3.x86_64.rpm
37-
ncurses-6.4-2.azl3.x86_64.rpm
38-
ncurses-compat-6.4-2.azl3.x86_64.rpm
39-
ncurses-devel-6.4-2.azl3.x86_64.rpm
40-
ncurses-libs-6.4-2.azl3.x86_64.rpm
41-
ncurses-term-6.4-2.azl3.x86_64.rpm
37+
ncurses-6.4-3.azl3.x86_64.rpm
38+
ncurses-compat-6.4-3.azl3.x86_64.rpm
39+
ncurses-devel-6.4-3.azl3.x86_64.rpm
40+
ncurses-libs-6.4-3.azl3.x86_64.rpm
41+
ncurses-term-6.4-3.azl3.x86_64.rpm
4242
readline-8.2-2.azl3.x86_64.rpm
4343
readline-devel-8.2-2.azl3.x86_64.rpm
4444
libattr-2.5.2-1.azl3.x86_64.rpm

toolkit/resources/manifests/package/toolchain_aarch64.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -267,12 +267,12 @@ mpfr-4.2.1-1.azl3.aarch64.rpm
267267
mpfr-debuginfo-4.2.1-1.azl3.aarch64.rpm
268268
mpfr-devel-4.2.1-1.azl3.aarch64.rpm
269269
msopenjdk-17-17.0.12-1.aarch64.rpm
270-
ncurses-6.4-2.azl3.aarch64.rpm
271-
ncurses-compat-6.4-2.azl3.aarch64.rpm
272-
ncurses-debuginfo-6.4-2.azl3.aarch64.rpm
273-
ncurses-devel-6.4-2.azl3.aarch64.rpm
274-
ncurses-libs-6.4-2.azl3.aarch64.rpm
275-
ncurses-term-6.4-2.azl3.aarch64.rpm
270+
ncurses-6.4-3.azl3.aarch64.rpm
271+
ncurses-compat-6.4-3.azl3.aarch64.rpm
272+
ncurses-debuginfo-6.4-3.azl3.aarch64.rpm
273+
ncurses-devel-6.4-3.azl3.aarch64.rpm
274+
ncurses-libs-6.4-3.azl3.aarch64.rpm
275+
ncurses-term-6.4-3.azl3.aarch64.rpm
276276
newt-0.52.23-1.azl3.aarch64.rpm
277277
newt-debuginfo-0.52.23-1.azl3.aarch64.rpm
278278
newt-devel-0.52.23-1.azl3.aarch64.rpm

toolkit/resources/manifests/package/toolchain_x86_64.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -275,12 +275,12 @@ mpfr-4.2.1-1.azl3.x86_64.rpm
275275
mpfr-debuginfo-4.2.1-1.azl3.x86_64.rpm
276276
mpfr-devel-4.2.1-1.azl3.x86_64.rpm
277277
msopenjdk-17-17.0.12-1.x86_64.rpm
278-
ncurses-6.4-2.azl3.x86_64.rpm
279-
ncurses-compat-6.4-2.azl3.x86_64.rpm
280-
ncurses-debuginfo-6.4-2.azl3.x86_64.rpm
281-
ncurses-devel-6.4-2.azl3.x86_64.rpm
282-
ncurses-libs-6.4-2.azl3.x86_64.rpm
283-
ncurses-term-6.4-2.azl3.x86_64.rpm
278+
ncurses-6.4-3.azl3.x86_64.rpm
279+
ncurses-compat-6.4-3.azl3.x86_64.rpm
280+
ncurses-debuginfo-6.4-3.azl3.x86_64.rpm
281+
ncurses-devel-6.4-3.azl3.x86_64.rpm
282+
ncurses-libs-6.4-3.azl3.x86_64.rpm
283+
ncurses-term-6.4-3.azl3.x86_64.rpm
284284
newt-0.52.23-1.azl3.x86_64.rpm
285285
newt-debuginfo-0.52.23-1.azl3.x86_64.rpm
286286
newt-devel-0.52.23-1.azl3.x86_64.rpm

0 commit comments

Comments
 (0)