Skip to content

Commit d643051

Browse files
authored
Update musl-wrapper version to 1.2.5 and apply CVE patch (#627)
1 parent 58eafe5 commit d643051

File tree

4 files changed

+82
-1
lines changed

4 files changed

+82
-1
lines changed

src/SPC/doctor/item/LinuxMuslCheck.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use SPC\store\Downloader;
1616
use SPC\store\FileSystem;
1717
use SPC\store\PackageManager;
18+
use SPC\store\SourcePatcher;
1819

1920
class LinuxMuslCheck
2021
{
@@ -63,14 +64,18 @@ public function fixMusl(): bool
6364
logger()->warning('Current user is not root, using sudo for running command');
6465
}
6566
// The hardcoded version here is to be consistent with the version compiled by `musl-cross-toolchain`.
66-
$musl_version_name = 'musl-1.2.4';
67+
$musl_version_name = 'musl-1.2.5';
6768
$musl_source = [
6869
'type' => 'url',
6970
'url' => "https://musl.libc.org/releases/{$musl_version_name}.tar.gz",
7071
];
7172
logger()->info('Downloading ' . $musl_source['url']);
7273
Downloader::downloadSource($musl_version_name, $musl_source);
7374
FileSystem::extractSource($musl_version_name, DOWNLOAD_PATH . "/{$musl_version_name}.tar.gz");
75+
76+
// Apply CVE-2025-26519 patch
77+
SourcePatcher::patchFile('musl-1.2.5_CVE-2025-26519_0001.patch', SOURCE_PATH . "/{$musl_version_name}");
78+
SourcePatcher::patchFile('musl-1.2.5_CVE-2025-26519_0002.patch', SOURCE_PATH . "/{$musl_version_name}");
7479
logger()->info('Installing musl wrapper');
7580
shell()->cd(SOURCE_PATH . "/{$musl_version_name}")
7681
->exec('CC=gcc CXX=g++ AR=ar LD=ld ./configure --disable-gcc-wrapper')
@@ -98,6 +103,7 @@ public function fixMuslCrossMake(): bool
98103
logger()->warning('Current user is not root, using sudo for running command');
99104
}
100105
$arch = arch2gnu(php_uname('m'));
106+
logger()->info("Downloading package musl-toolchain-{$arch}-linux");
101107
PackageManager::installPackage("musl-toolchain-{$arch}-linux");
102108
$pkg_root = PKG_ROOT_PATH . "/musl-toolchain-{$arch}-linux";
103109
shell()->exec("{$prefix}cp -rf {$pkg_root}/* /usr/local/musl");
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
>From e5adcd97b5196e29991b524237381a0202a60659 Mon Sep 17 00:00:00 2001
2+
From: Rich Felker <[email protected]>
3+
Date: Sun, 9 Feb 2025 10:07:19 -0500
4+
Subject: [PATCH] iconv: fix erroneous input validation in EUC-KR decoder
5+
6+
as a result of incorrect bounds checking on the lead byte being
7+
decoded, certain invalid inputs which should produce an encoding
8+
error, such as "\xc8\x41", instead produced out-of-bounds loads from
9+
the ksc table.
10+
11+
in a worst case, the loaded value may not be a valid unicode scalar
12+
value, in which case, if the output encoding was UTF-8, wctomb would
13+
return (size_t)-1, causing an overflow in the output pointer and
14+
remaining buffer size which could clobber memory outside of the output
15+
buffer.
16+
17+
bug report was submitted in private by Nick Wellnhofer on account of
18+
potential security implications.
19+
---
20+
src/locale/iconv.c | 2 +-
21+
1 file changed, 1 insertion(+), 1 deletion(-)
22+
23+
diff --git a/src/locale/iconv.c b/src/locale/iconv.c
24+
index 9605c8e9..008c93f0 100644
25+
--- a/src/locale/iconv.c
26+
+++ b/src/locale/iconv.c
27+
@@ -502,7 +502,7 @@ size_t iconv(iconv_t cd, char **restrict in, size_t *restrict inb, char **restri
28+
if (c >= 93 || d >= 94) {
29+
c += (0xa1-0x81);
30+
d += 0xa1;
31+
- if (c >= 93 || c>=0xc6-0x81 && d>0x52)
32+
+ if (c > 0xc6-0x81 || c==0xc6-0x81 && d>0x52)
33+
goto ilseq;
34+
if (d-'A'<26) d = d-'A';
35+
else if (d-'a'<26) d = d-'a'+26;
36+
--
37+
2.21.0
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
>From c47ad25ea3b484e10326f933e927c0bc8cded3da Mon Sep 17 00:00:00 2001
2+
From: Rich Felker <[email protected]>
3+
Date: Wed, 12 Feb 2025 17:06:30 -0500
4+
Subject: [PATCH] iconv: harden UTF-8 output code path against input decoder
5+
bugs
6+
7+
the UTF-8 output code was written assuming an invariant that iconv's
8+
decoders only emit valid Unicode Scalar Values which wctomb can encode
9+
successfully, thereby always returning a value between 1 and 4.
10+
11+
if this invariant is not satisfied, wctomb returns (size_t)-1, and the
12+
subsequent adjustments to the output buffer pointer and remaining
13+
output byte count overflow, moving the output position backwards,
14+
potentially past the beginning of the buffer, without storing any
15+
bytes.
16+
---
17+
src/locale/iconv.c | 4 ++++
18+
1 file changed, 4 insertions(+)
19+
20+
diff --git a/src/locale/iconv.c b/src/locale/iconv.c
21+
index 008c93f0..52178950 100644
22+
--- a/src/locale/iconv.c
23+
+++ b/src/locale/iconv.c
24+
@@ -545,6 +545,10 @@ size_t iconv(iconv_t cd, char **restrict in, size_t *restrict inb, char **restri
25+
if (*outb < k) goto toobig;
26+
memcpy(*out, tmp, k);
27+
} else k = wctomb_utf8(*out, c);
28+
+ /* This failure condition should be unreachable, but
29+
+ * is included to prevent decoder bugs from translating
30+
+ * into advancement outside the output buffer range. */
31+
+ if (k>4) goto ilseq;
32+
*out += k;
33+
*outb -= k;
34+
break;
35+
--
36+
2.21.0

src/globals/test-extensions.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
// test php version
1515
$test_php_version = [
16+
'8.1',
17+
'8.2',
1618
'8.3',
1719
'8.4',
1820
];

0 commit comments

Comments
 (0)