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

From: Date: Sun, 01 Nov 2026 06:34:30 +0000
Subject: [php-src] master: Merge branch 'PHP-8.5' into PHP-8.6
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-143110@lists.php.net to get a copy of this message
Author: Weilin Du (LamentXU123) Date: 2026-11-01T14:29:43+08:00 Commit: https://github.com/php/php-src/commit/635c85d89f80208859283e7924ccad1390c44479 Raw diff: https://github.com/php/php-src/commit/635c85d89f80208859283e7924ccad1390c44479.diff Merge branch 'PHP-8.5' into PHP-8.6 * PHP-8.5: 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 3ede84fe63ed..9004019b3a59 100644 --- a/NEWS +++ b/NEWS @@ -151,6 +151,8 @@ PHP NEWS PgBouncer's prepared statements). (David Carlier, Artem Ukrainskiy) - 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 8703979f234b..b1cfd897fa6c 100644 --- a/ext/phar/zip.c +++ b/ext/phar/zip.c @@ -645,7 +645,6 @@ zend_result phar_parse_zipfile( zend_off_t restore_pos = php_stream_tell(fp); php_stream_seek(fp, entry.offset, SEEK_SET); - 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)); @@ -732,6 +731,8 @@ zend_result phar_parse_zipfile( } } + mydata->alias_len = entry.uncompressed_filesize; + /* return to central directory parsing */ php_stream_seek(fp, restore_pos, SEEK_SET); }

« previous php.cvs (#143110) next »