[php-src] master: Merge branch 'PHP-8.5' into PHP-8.6
| From: | Jakub Zelenka | Date: | Tue, 27 Oct 2026 17:54:01 +0000 |
| Subject: | [php-src] master: Merge branch 'PHP-8.5' into PHP-8.6 | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-142839@lists.php.net to get a copy of this message | ||
Author: Jakub Zelenka (bukka)
Date: 2026-10-27T18:52:12+01:00
Commit: https://github.com/php/php-src/commit/2df07dd25ed58aef40ed6a6c61c1afdb9547e5ad
Raw diff: https://github.com/php/php-src/commit/2df07dd25ed58aef40ed6a6c61c1afdb9547e5ad.diff
Merge branch 'PHP-8.5' into PHP-8.6
* PHP-8.5:
fpm: fix _GET_str memory leaks and test headers_only status path
fpm: fix a use-after-free of scoreboard_p
fpm: fix potential null dereference in fpm_status_export_to_zval()
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 ac066ed50cbb..07a223904848 100644
--- a/NEWS
+++ b/NEWS
@@ -34,6 +34,12 @@ 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
+ copy fails. (Marcel Hernandez)
- Hash:
. Fix GOST and Snefru digests of 512 MiB or more. (Martin Mirchev)
diff --git a/sapi/fpm/fpm/fpm_status.c b/sapi/fpm/fpm/fpm_status.c
index ff6ef68f3949..118be47bfeee 100644
--- a/sapi/fpm/fpm/fpm_status.c
+++ b/sapi/fpm/fpm/fpm_status.c
@@ -56,6 +56,9 @@ int fpm_status_export_to_zval(zval *status)
int i;
scoreboard_p = fpm_scoreboard_copy(NULL, 1);
+ if (!scoreboard_p) {
+ return -1;
+ }
now_epoch = time(NULL);
fpm_clock_get(&now);
@@ -180,17 +183,19 @@ 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;
}
if (scoreboard_p->idle < 0 || scoreboard_p->active < 0) {
- fpm_scoreboard_free_copy(scoreboard_p);
zlog(ZLOG_ERROR, "[pool %s] invalid status values", scoreboard_p->pool);
SG(sapi_headers).http_response_code = 500;
sapi_add_header_ex(ZEND_STRL("Content-Type: text/plain"), 1, 1);
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;
}
@@ -201,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();
+?>