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

From: Date: Sun, 01 Nov 2026 15:19:13 +0000
Subject: [php-src] master: Merge branch 'PHP-8.4' into PHP-8.5
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-143156@lists.php.net to get a copy of this message
Author: Ilia Alshanetsky (iliaal) Date: 2026-11-01T10:11:52-05:00 Commit: https://github.com/php/php-src/commit/7c0b41ed3ef7636c7e302e1326015fc2c6047f5d Raw diff: https://github.com/php/php-src/commit/7c0b41ed3ef7636c7e302e1326015fc2c6047f5d.diff Merge branch 'PHP-8.4' into PHP-8.5 * PHP-8.4: Fix GH-24531: Crash when flushing a renamed zip-based phar Changed paths: A ext/phar/tests/zip/gh24531.phpt M NEWS M ext/phar/zip.c Diff: diff --git a/NEWS b/NEWS index a72e55a0d7c0..75256b65a316 100644 --- a/NEWS +++ b/NEWS @@ -235,6 +235,8 @@ PHP NEWS are equal). (Lazizbek Ergashev) . Fixed bug GH-25092 (Double free in Phar::copy() on link and mounted entries). (Lazizbek Ergashev) + . Fixed bug GH-24531 (Crash when modifying a zip-based phar whose file was + renamed). (Ilia Alshanetsky) - Phpdbg: . Fix wrong command names. (ndossche, Weilin Du) diff --git a/ext/phar/tests/zip/gh24531.phpt b/ext/phar/tests/zip/gh24531.phpt new file mode 100644 index 000000000000..44f9e1736060 --- /dev/null +++ b/ext/phar/tests/zip/gh24531.phpt @@ -0,0 +1,32 @@ +--TEST-- +GH-24531 (NULL pointer dereference when flushing a zip-based phar whose file was renamed) +--EXTENSIONS-- +phar +--INI-- +phar.readonly=0 +phar.require_hash=0 +--FILE-- +<?php +$source = __DIR__ . '/gh24531.phar.zip'; +$target = __DIR__ . '/gh24531-renamed.phar.zip'; + +$phar = new Phar($source); +$phar->addFromString('first', 'first'); +unset($phar); + +rename($source, $target); + +try { + $phar = new Phar($source); + $phar->addFromString('second', 'second'); +} catch (PharException $e) { + echo $e::class, ": ", $e->getMessage(), PHP_EOL; +} +?> +--CLEAN-- +<?php +@unlink(__DIR__ . '/gh24531.phar.zip'); +@unlink(__DIR__ . '/gh24531-renamed.phar.zip'); +?> +--EXPECTF-- +PharException: phar zip flush of "%sgh24531.phar.zip" failed: unable to copy contents of file "first" while creating zip-based phar "%sgh24531.phar.zip" diff --git a/ext/phar/zip.c b/ext/phar/zip.c index 1411bfeb0a8d..31bc464d19ef 100644 --- a/ext/phar/zip.c +++ b/ext/phar/zip.c @@ -1155,7 +1155,7 @@ static int phar_zip_changed_apply_int(phar_entry_info *entry, void *arg) /* {{{ } } - if (!entry->is_dir && entry->compressed_filesize && SUCCESS != php_stream_copy_to_stream_ex(p->old, p->filefp, entry->compressed_filesize, NULL)) { + if (!entry->is_dir && entry->compressed_filesize && (!p->old || SUCCESS != php_stream_copy_to_stream_ex(p->old, p->filefp, entry->compressed_filesize, NULL))) { spprintf(p->error, 0, "unable to copy contents of file \"%s\" while creating zip-based phar \"%s\"", ZSTR_VAL(entry->filename), entry->phar->fname); return ZEND_HASH_APPLY_STOP; }

« previous php.cvs (#143156) next »