[php-src] PR #21802: phar: fix NULL dereference in Phar::webPhar() when SCRIPT_NAME is absent
| From: | iliaal | Date: | Sat, 18 Apr 2026 13:39:07 +0000 |
| Subject: | [php-src] PR #21802: phar: fix NULL dereference in Phar::webPhar() when SCRIPT_NAME is absent | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-35773@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/21802
Author: iliaal
In the CGI/FastCGI branch of
webPhar(),
sapi_getenv("SCRIPT_NAME") can return NULL when the upstream server
doesn't forward SCRIPT_NAME in the FastCGI params block. The return value was
passed directly to strstr() without a NULL check, causing a segfault.
Add a NULL guard that jumps to the finish: label, which is already used for the
"SCRIPT_NAME doesn't match the phar basename" case. The fix matches the intent of the
existing strstr check and requires no new cleanup.
Fixes #21797