Skip to content

Commit 30d7b43

Browse files
committed
phar: exercise CGI branch in gh21797 regression test
Set variables_order=EGPC, register_argc_argv=0 and cgi.fix_pathinfo=0 to keep TRACK_VARS_SERVER IS_UNDEF and route through the pre-4.3 CGI path, which leaves SCRIPT_NAME unset while still populating request_uri from PATH_INFO. This reaches the sapi_getenv(SCRIPT_NAME) -> NULL call that the fix guards against; the prior CLI stub never entered the CGI/FastCGI branch at all.
1 parent 66e4d38 commit 30d7b43

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

ext/phar/tests/gh21797.phpt

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,28 @@
11
--TEST--
22
GH-21797: Phar::webPhar() NULL dereference when SCRIPT_NAME absent from SAPI environment
3+
--CGI--
34
--EXTENSIONS--
45
phar
56
--INI--
67
phar.readonly=0
78
phar.require_hash=0
9+
variables_order=EGPC
10+
register_argc_argv=0
11+
cgi.fix_pathinfo=0
12+
--ENV--
13+
REQUEST_METHOD=GET
14+
PATH_INFO=/gh21797.phar
815
--FILE--
916
<?php
10-
// The NULL dereference in the CGI/FastCGI branch of webPhar() is not
11-
// reachable from CLI SAPI. This test exercises the CLI code path as a
12-
// regression baseline and verifies the function behaves correctly when
13-
// called outside an HTTP context.
14-
1517
$fname = __DIR__ . '/' . basename(__FILE__, '.php') . '.phar';
16-
1718
$phar = new Phar($fname);
1819
$phar->addFromString('index.php', '<?php echo "ok\n"; ?>');
1920
$phar->setStub('<?php
2021
Phar::webPhar();
22+
echo "no crash\n";
2123
__HALT_COMPILER(); ?>');
2224
unset($phar);
23-
24-
// webPhar() with no HTTP context returns silently (no request method set)
2525
include $fname;
26-
echo "no crash\n";
2726
?>
2827
--CLEAN--
2928
<?php @unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar'); ?>

0 commit comments

Comments
 (0)