[php-src] PHP-8.6: Merge branch 'PHP-8.4' into PHP-8.5

From: Date: Sun, 01 Nov 2026 06:34:28 +0000
Subject: [php-src] PHP-8.6: Merge branch 'PHP-8.4' into PHP-8.5
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-143112@lists.php.net to get a copy of this message
Author: Weilin Du (LamentXU123) Date: 2026-11-01T14:25:15+08:00 Commit: https://github.com/php/php-src/commit/2283aa1fac94e1f1b5b918ef5437b9f9c0bcb446 Raw diff: https://github.com/php/php-src/commit/2283aa1fac94e1f1b5b918ef5437b9f9c0bcb446.diff Merge branch 'PHP-8.4' into PHP-8.5 * PHP-8.4: Fix GH-25089: Heap buffer over-read via crafted alias size in zip-based phar (#25099) Changed paths: A ext/phar/tests/zip/gh25089.phpt M NEWS M ext/phar/zip.c Diff: diff --git a/NEWS b/NEWS index 2e1c9af51b07..557d2a3783d9 100644 --- a/NEWS +++ b/NEWS @@ -220,6 +220,8 @@ PHP NEWS out-of-range column index). (Ilia Alshanetsky) - Phar: + . Fixed bug GH-25089 (Heap buffer over-read via crafted alias size in + zip-based phar). (Lazizbek Ergashev) . Fixed bug GH-8469 (Phar::decompressFiles() and Phar::compressFiles() retain compressed contents after changing compression). (Raphael Paez) . Fixed bug GH-24740 (Oversized tar metadata exhausts the memory limit). diff --git a/ext/phar/tests/zip/gh25089.phpt b/ext/phar/tests/zip/gh25089.phpt new file mode 100644 index 000000000000..ec68c035f0c4 --- /dev/null +++ b/ext/phar/tests/zip/gh25089.phpt @@ -0,0 +1,35 @@ +--TEST-- +GH-25089 (Heap buffer over-read via crafted alias size in zip-based phar) +--EXTENSIONS-- +phar +zlib +--FILE-- +<?php +$name = '.phar/alias.txt'; +$alias = 'ABCD'; +$data = gzdeflate($alias); +$crc = crc32($alias); +$claimed = 0x1000; + +$local = "PK\x03\x04" + . pack('vvvvvVVVvv', 20, 0, 8, 0, 0, + $crc, strlen($data), $claimed, strlen($name), 0) + . $name . $data; +$central = "PK\x01\x02" + . pack('vvvvvvVVVvvvvvVV', 20, 20, 0, 8, 0, 0, + $crc, strlen($data), $claimed, strlen($name), 0, 0, 0, 0, 0, 0) + . $name; +$end = "PK\x05\x06" + . pack('vvvvVVv', 0, 0, 1, 1, strlen($central), strlen($local), 0); + +file_put_contents(__DIR__ . '/gh25089.zip', $local . $central . $end); + +$phar = new PharData(__DIR__ . '/gh25089.zip'); +var_dump($phar->getAlias()); +?> +--CLEAN-- +<?php +@unlink(__DIR__ . '/gh25089.zip'); +?> +--EXPECT-- +string(4) "ABCD" diff --git a/ext/phar/zip.c b/ext/phar/zip.c index 71462f5e9f25..1411bfeb0a8d 100644 --- a/ext/phar/zip.c +++ b/ext/phar/zip.c @@ -649,7 +649,6 @@ int phar_parse_zipfile(php_stream *fp, char *fname, size_t fname_len, char *alia fp->readpos = 0; /* the above lines should be for php < 5.2.6 after 5.3 filters are fixed */ - mydata->alias_len = entry.uncompressed_filesize; if (entry.flags & PHAR_ENT_COMPRESSED_GZ) { filter = php_stream_filter_create("zlib.inflate", NULL, php_stream_is_persistent(fp)); @@ -736,6 +735,8 @@ int phar_parse_zipfile(php_stream *fp, char *fname, size_t fname_len, char *alia } } + mydata->alias_len = entry.uncompressed_filesize; + /* return to central directory parsing */ php_stream_seek(fp, restore_pos, SEEK_SET); }

« previous php.cvs (#143112) next »