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

From: Date: Mon, 02 Nov 2026 06:29:51 +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-143201@lists.php.net to get a copy of this message
Author: Weilin Du (LamentXU123) Date: 2026-11-02T14:20:32+08:00 Commit: https://github.com/php/php-src/commit/1e760d19649253f739fd223310c8da7888266b40 Raw diff: https://github.com/php/php-src/commit/1e760d19649253f739fd223310c8da7888266b40.diff Merge branch 'PHP-8.5' into PHP-8.6 * PHP-8.5: Merge branch 'PHP-8.4' into PHP-8.5 Changed paths: A ext/phar/tests/gh25093.phpt M NEWS M ext/phar/phar_object.c Diff: diff --git a/NEWS b/NEWS index ce22cecb3c8f..0e6eefd350e1 100644 --- a/NEWS +++ b/NEWS @@ -158,6 +158,8 @@ PHP NEWS PgBouncer's prepared statements). (David Carlier, Artem Ukrainskiy) - Phar: + . Fixed bug GH-25093 (Phar::webPhar() redirect reads past the request URI). + (lazerg) . 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 diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c index fdf5a3914bee..9d3bd842cb72 100644 --- a/ext/phar/phar_object.c +++ b/ext/phar/phar_object.c @@ -766,7 +766,7 @@ PHP_METHOD(Phar, webPhar) sapi_header_op(SAPI_HEADER_REPLACE, &ctr); if (not_cgi) { - tmp = strstr(path_info, basename) + fname_len; + tmp = strstr(path_info, basename) + (fname_len - (basename - fname)); sa = *tmp; *tmp = '\0'; } diff --git a/ext/phar/tests/gh25093.phpt b/ext/phar/tests/gh25093.phpt new file mode 100644 index 000000000000..442a95e63c7a --- /dev/null +++ b/ext/phar/tests/gh25093.phpt @@ -0,0 +1,47 @@ +--TEST-- +GH-25093: Phar::webPhar() redirect reads past the request URI +--EXTENSIONS-- +phar +--SKIPIF-- +<?php +if (!file_exists(__DIR__ . "/../../../sapi/cli/tests/php_cli_server.inc")) { + echo "skip sapi/cli/tests/php_cli_server.inc required but not found"; +} +?> +--CONFLICTS-- +server +--INI-- +phar.readonly=0 +phar.require_hash=0 +--FILE-- +<?php +include __DIR__ . "/../../../sapi/cli/tests/php_cli_server.inc"; + +$args = ["-d", "extension_dir=" . ini_get("extension_dir"), "-d", "extension=" . (substr(PHP_OS, 0, 3) == "WIN" ? "php_" : "") . "phar." . PHP_SHLIB_SUFFIX]; +if (php_ini_loaded_file()) { + $args[] = "-c"; + $args[] = php_ini_loaded_file(); +} +$info = php_cli_server_start('include __DIR__ . "/gh25093.phar";', 'router.php', $args); + +$phar = new Phar($info->docRoot . '/gh25093.phar'); +$phar->addFromString('index.php', '<?php echo "index\n";'); +$phar->setStub('<?php +Phar::webPhar(null, "index.php", null, [], function ($path) { + return "/"; +}); +__HALT_COMPILER(); ?>'); +unset($phar); + +$context = stream_context_create(['http' => ['follow_location' => 0]]); +$uri = '/gh25093.phar/' . str_repeat('a', strlen($info->docRoot) + 32); +file_get_contents('http://' . PHP_CLI_SERVER_ADDRESS . $uri, false, $context); + +foreach (http_get_last_response_headers() as $header) { + if (str_starts_with($header, 'Location: ')) { + echo $header, "\n"; + } +} +?> +--EXPECT-- +Location: /gh25093.phar/index.php

« previous php.cvs (#143201) next »