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

From: Date: Sun, 01 Nov 2026 15:19:13 +0000
Subject: [php-src] PHP-8.6: Merge branch 'PHP-8.5' into PHP-8.6
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-143155@lists.php.net to get a copy of this message
Author: Ilia Alshanetsky (iliaal) Date: 2026-11-01T10:12:13-05:00 Commit: https://github.com/php/php-src/commit/0f5866cf14b22e31f540b81a00a5a13e02d58e50 Raw diff: https://github.com/php/php-src/commit/0f5866cf14b22e31f540b81a00a5a13e02d58e50.diff Merge branch 'PHP-8.5' into PHP-8.6 * PHP-8.5: 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 a9bb0d16f780..d7dc0e39c3ac 100644 --- a/NEWS +++ b/NEWS @@ -166,6 +166,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) - Reflection: . Fixed bug GH-21768 (Assertion failure in ReflectionProperty::isReadable() 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 b1cfd897fa6c..13c34d8a3b0f 100644 --- a/ext/phar/zip.c +++ b/ext/phar/zip.c @@ -1152,7 +1152,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), ZSTR_VAL(entry->phar->fname)); return ZEND_HASH_APPLY_STOP; }

« previous php.cvs (#143155) next »