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

From: Date: Mon, 02 Nov 2026 06:29:51 +0000
Subject: [php-src] PHP-8.5: Merge branch 'PHP-8.4' into PHP-8.5
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-143199@lists.php.net to get a copy of this message
Author: Weilin Du (LamentXU123) Date: 2026-11-02T14:19:26+08:00 Commit: https://github.com/php/php-src/commit/722feedf42d9dcd049afd1db0ae631b74635e290 Raw diff: https://github.com/php/php-src/commit/722feedf42d9dcd049afd1db0ae631b74635e290.diff Merge branch 'PHP-8.4' into PHP-8.5 * PHP-8.4: Fix GH-25093: Phar::webPhar() redirect reads past the request URI (#25102) Changed paths: A ext/phar/tests/gh25093.phpt M NEWS M ext/phar/phar_object.c Diff: diff --git a/NEWS b/NEWS index 2248d6a292e4..485dfd139b35 100644 --- a/NEWS +++ b/NEWS @@ -224,6 +224,8 @@ PHP NEWS out-of-range column index). (Ilia Alshanetsky) - 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 c0285390ba4e..5ce6f39a5777 100644 --- a/ext/phar/phar_object.c +++ b/ext/phar/phar_object.c @@ -784,7 +784,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 (#143199) next »