Skip to content

Commit 5bc6231

Browse files
committed
Auto merge of #137127 - pietroalbini:pa-musl-cve-2025-26519, r=jieyouxu
Fix musl's CVE-2025-26519 The musl project [announced CVE-2025-26519](https://www.openwall.com/lists/musl/2025/02/13/1), which could result in out-of-bounds writes when calling the `iconv` function. There is no musl release available with the fixes at this point in time (and we're using an older version of musl anyway), so this PR applies the provided patches on top of the musl source tarball we download.
2 parents a3d4bd3 + a6ee2f4 commit 5bc6231

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

src/ci/docker/scripts/musl.sh

+41
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,47 @@ MUSL=musl-1.2.3
3030
# may have been downloaded in a previous run
3131
if [ ! -d $MUSL ]; then
3232
curl https://www.musl-libc.org/releases/$MUSL.tar.gz | tar xzf -
33+
34+
# Apply patches for CVE-2025-26519. At the time of adding these patches no release containing them
35+
# has been published by the musl project, so we just apply them directly on top of the version we
36+
# were distributing already. The patches should be removed once we upgrade to musl >= 1.2.6.
37+
#
38+
# Advisory: https://www.openwall.com/lists/musl/2025/02/13/1
39+
#
40+
# Patches applied:
41+
# - https://www.openwall.com/lists/musl/2025/02/13/1/1
42+
# - https://www.openwall.com/lists/musl/2025/02/13/1/2
43+
#
44+
# ignore-tidy-tab
45+
# ignore-tidy-linelength
46+
patch -p1 -d $MUSL <<EOF
47+
--- a/src/locale/iconv.c
48+
+++ b/src/locale/iconv.c
49+
@@ -502,7 +502,7 @@ size_t iconv(iconv_t cd, char **restrict in, size_t *restrict inb, char **restri
50+
if (c >= 93 || d >= 94) {
51+
c += (0xa1-0x81);
52+
d += 0xa1;
53+
- if (c >= 93 || c>=0xc6-0x81 && d>0x52)
54+
+ if (c > 0xc6-0x81 || c==0xc6-0x81 && d>0x52)
55+
goto ilseq;
56+
if (d-'A'<26) d = d-'A';
57+
else if (d-'a'<26) d = d-'a'+26;
58+
EOF
59+
patch -p1 -d $MUSL <<EOF
60+
--- a/src/locale/iconv.c
61+
+++ b/src/locale/iconv.c
62+
@@ -545,6 +545,10 @@ size_t iconv(iconv_t cd, char **restrict in, size_t *restrict inb, char **restri
63+
if (*outb < k) goto toobig;
64+
memcpy(*out, tmp, k);
65+
} else k = wctomb_utf8(*out, c);
66+
+ /* This failure condition should be unreachable, but
67+
+ * is included to prevent decoder bugs from translating
68+
+ * into advancement outside the output buffer range. */
69+
+ if (k>4) goto ilseq;
70+
*out += k;
71+
*outb -= k;
72+
break;
73+
EOF
3374
fi
3475

3576
cd $MUSL

0 commit comments

Comments
 (0)