diff --git a/main/SAPI.c b/main/SAPI.c index 09b028e55166..d0226ded65be 100644 --- a/main/SAPI.c +++ b/main/SAPI.c @@ -507,12 +507,15 @@ SAPI_API void sapi_deactivate_module(void) } if (SG(request_info).auth_user) { efree(SG(request_info).auth_user); + SG(request_info).auth_user = NULL; } if (SG(request_info).auth_password) { efree(SG(request_info).auth_password); + SG(request_info).auth_password = NULL; } if (SG(request_info).auth_digest) { efree(SG(request_info).auth_digest); + SG(request_info).auth_digest = NULL; } if (SG(request_info).content_type_dup) { efree(SG(request_info).content_type_dup); diff --git a/main/main.c b/main/main.c index 0adecd10ffcc..a3889bb3c5b4 100644 --- a/main/main.c +++ b/main/main.c @@ -2672,7 +2672,12 @@ PHPAPI int php_handle_auth_data(const char *auth) if (pass) { *pass++ = '\0'; SG(request_info).auth_user = estrndup(ZSTR_VAL(user), ZSTR_LEN(user)); - SG(request_info).auth_password = estrdup(pass); + + if (strlen(pass) > 0) { + SG(request_info).auth_password = estrdup(pass); + } else { + SG(request_info).auth_password = NULL; + } ret = 0; } zend_string_free(user); diff --git a/sapi/fpm/tests/gh15395.phpt b/sapi/fpm/tests/gh15395.phpt new file mode 100644 index 000000000000..82abca85e09c --- /dev/null +++ b/sapi/fpm/tests/gh15395.phpt @@ -0,0 +1,72 @@ +--TEST-- +GH-15335 data logging during shutdown +--SKIPIF-- + +--FILE-- +createSourceFileAndScriptName(); +$tester->start(); +$tester->expectLogStartNotices(); +$tester + ->request( + uri: $scriptName, + address: '{{ADDR:UDS}}', + scriptFilename: "/", + scriptName: "/", + headers: ["HTTP_AUTHORIZATION" => "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==", "REQUEST_METHOD" => "GET"], + ) + ->expectStatus('404 Not Found'); +$tester->terminate(); +$tester->expectLogTerminatingNotices(); +$tester->close(); + +$tester = new FPM\Tester($cfg, $code); +[$sourceFilePath, $scriptName] = $tester->createSourceFileAndScriptName(); +$tester->start(); +$tester->expectLogStartNotices(); +$tester + ->request( + uri: $scriptName, + address: '{{ADDR:UDS}}', + scriptFilename: $sourceFilePath, + scriptName: $scriptName, + ) + ->expectBody([$scriptName, $sourceFilePath, $scriptName]); +$tester->terminate(); +$tester->expectLogTerminatingNotices(); +$tester->close(); + +?> +Done +--EXPECT-- +Done +--CLEAN-- + +