[php-src] PHP-8.4: fpm: fix _GET_str memory leaks and test headers_only status path
| From: | Marcel Hernandez via Jakub Zelenka | Date: | Tue, 27 Oct 2026 17:53:59 +0000 |
| Subject: | [php-src] PHP-8.4: fpm: fix _GET_str memory leaks and test headers_only status path | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-142841@lists.php.net to get a copy of this message | ||
Author: Marcel Hernandez (1ma)
Committer: Jakub Zelenka (bukka)
Date: 2026-10-27T18:50:07+01:00
Commit: https://github.com/php/php-src/commit/0e7e36c8969ee5d49cdd76e693522c44f8f3a785
Raw diff: https://github.com/php/php-src/commit/0e7e36c8969ee5d49cdd76e693522c44f8f3a785.diff
fpm: fix _GET_str memory leaks and test headers_only status path
Closes GH-23833
Changed paths:
A sapi/fpm/tests/status-head.phpt
M NEWS
M sapi/fpm/fpm/fpm_status.c
Diff:
diff --git a/NEWS b/NEWS
index f1d8974b0bfc..1bf9bfb06679 100644
--- a/NEWS
+++ b/NEWS
@@ -78,6 +78,8 @@ PHP NEWS
. Fixed bug GH-24046 (FPM worker stdio pipe fd closed twice when a child
process outlives the worker, breaking a later worker's stdio).
(Ian P. Christian, ndossche)
+ . Fixed memory leaks of the _GET string on the status page error and HEAD
+ request paths. (Marcel Hernandez)
. Fixed use-after-free of the scoreboard copy when logging invalid status
values. (Marcel Hernandez)
. Fixed null pointer dereference in fpm_get_status() when the scoreboard
diff --git a/sapi/fpm/fpm/fpm_status.c b/sapi/fpm/fpm/fpm_status.c
index f030bb309ae4..118be47bfeee 100644
--- a/sapi/fpm/fpm/fpm_status.c
+++ b/sapi/fpm/fpm/fpm_status.c
@@ -183,6 +183,7 @@ int fpm_status_handle_request(void) /* {{{ */
sapi_add_header_ex(ZEND_STRL("Expires: Thu, 01 Jan 1970 00:00:00 GMT"), 1, 1);
sapi_add_header_ex(ZEND_STRL("Cache-Control: no-cache, no-store, must-revalidate,
max-age=0"), 1, 1);
PUTS("Internal error. Please review log file for errors.");
+ zend_string_release_ex(_GET_str, 0);
return 1;
}
@@ -193,6 +194,7 @@ int fpm_status_handle_request(void) /* {{{ */
sapi_add_header_ex(ZEND_STRL("Expires: Thu, 01 Jan 1970 00:00:00 GMT"), 1, 1);
sapi_add_header_ex(ZEND_STRL("Cache-Control: no-cache, no-store, must-revalidate,
max-age=0"), 1, 1);
PUTS("Internal error. Please review log file for errors.");
+ zend_string_release_ex(_GET_str, 0);
fpm_scoreboard_free_copy(scoreboard_p);
return 1;
}
@@ -204,6 +206,7 @@ int fpm_status_handle_request(void) /* {{{ */
/* handle HEAD */
if (SG(request_info).headers_only) {
+ zend_string_release_ex(_GET_str, 0);
fpm_scoreboard_free_copy(scoreboard_p);
return 1;
}
diff --git a/sapi/fpm/tests/status-head.phpt b/sapi/fpm/tests/status-head.phpt
new file mode 100644
index 000000000000..a21fb7a7f1f8
--- /dev/null
+++ b/sapi/fpm/tests/status-head.phpt
@@ -0,0 +1,40 @@
+--TEST--
+FPM: Status HEAD request returns headers without body
+--SKIPIF--
+<?php include "skipif.inc"; ?>
+--FILE--
+<?php
+
+require_once "tester.inc";
+
+$cfg = <<<EOT
+[global]
+error_log = {{FILE:LOG}}
+[unconfined]
+listen = {{ADDR}}
+pm = static
+pm.max_children = 1
+pm.status_path = /status
+EOT;
+
+$tester = new FPM\Tester($cfg);
+$tester->start();
+$tester->expectLogStartNotices();
+$tester->request()->expectEmptyBody();
+
+$response = $tester->request(uri: '/status', method: 'HEAD');
+$response->expectEmptyBody();
+
+$tester->terminate();
+$tester->expectLogTerminatingNotices();
+$tester->close();
+
+?>
+Done
+--EXPECT--
+Done
+--CLEAN--
+<?php
+require_once "tester.inc";
+FPM\Tester::clean();
+?>