[php-src] PHP-8.5: Merge branch 'PHP-8.4' into PHP-8.5
| From: | Jorg Sowa | Date: | Wed, 25 Nov 2026 17:07:15 +0000 |
| Subject: | [php-src] PHP-8.5: Merge branch 'PHP-8.4' into PHP-8.5 | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-144168@lists.php.net to get a copy of this message | ||
Author: Jorg Sowa (jorgsowa)
Date: 2026-11-25T18:02:43+01:00
Commit: https://github.com/php/php-src/commit/ab85c508feafb54c697f25530bdf43dfd34eb2ae
Raw diff: https://github.com/php/php-src/commit/ab85c508feafb54c697f25530bdf43dfd34eb2ae.diff
Merge branch 'PHP-8.4' into PHP-8.5
Changed paths:
A sapi/fpm/tests/log-limit-above-buffer-errno-msg.phpt
M NEWS
M sapi/fpm/fpm/zlog.c
Diff:
diff --git a/NEWS b/NEWS
index 9138f3586af8..7944df5c54b3 100644
--- a/NEWS
+++ b/NEWS
@@ -65,6 +65,10 @@ PHP NEWS
. Fixed stack overflow in filter_var() and filter_var_array() with deeply
nested arrays. (Eyüp Can Akman)
+- FPM:
+ . Fixed stack buffer overflow when logging an error with errno text and
+ log_limit above 2048. (Jorg Sowa)
+
- GD:
. Fixed imagecreatefromstring() continuing to decode after throwing for a
string longer than INT_MAX. (lacatoire)
diff --git a/sapi/fpm/fpm/zlog.c b/sapi/fpm/fpm/zlog.c
index f11618b94773..d5e28b4074f6 100644
--- a/sapi/fpm/fpm/zlog.c
+++ b/sapi/fpm/fpm/zlog.c
@@ -227,7 +227,7 @@ void vzlog(const char *function, int line, int flags, const char *fmt, va_list a
if (flags & ZLOG_HAVE_ERRNO) {
len += snprintf(buf + len, buf_size - len,
": %s (%d)", strerror(saved_errno), saved_errno);
- if (len >= zlog_limit) {
+ if (len >= zlog_limit || len >= buf_size) {
truncated = 1;
}
}
diff --git a/sapi/fpm/tests/log-limit-above-buffer-errno-msg.phpt
b/sapi/fpm/tests/log-limit-above-buffer-errno-msg.phpt
new file mode 100644
index 000000000000..641d2ada4aa2
--- /dev/null
+++ b/sapi/fpm/tests/log-limit-above-buffer-errno-msg.phpt
@@ -0,0 +1,38 @@
+--TEST--
+FPM: Log message with errno is truncated to the buffer when log_limit is above it
+--SKIPIF--
+<?php include "skipif.inc"; ?>
+--FILE--
+<?php
+
+require_once "tester.inc";
+
+/* The error line nearly fills the 2048-byte log buffer before errno text is appended. */
+$slowlog = '/' . str_repeat('a', 1970);
+
+$cfg = <<<EOT
+[global]
+error_log = {{FILE:LOG}}
+log_limit = 4096
+[unconfined]
+listen = {{ADDR}}
+pm = static
+pm.max_children = 1
+request_slowlog_timeout = 1
+slowlog = $slowlog
+EOT;
+
+$tester = new FPM\Tester($cfg);
+$tester->start();
+$tester->expectLogPattern('/^\[[^\]]+\] ERROR: Unable to create or open
slowlog\(\/a{1970}\): .{7}\.\.\.$/');
+$tester->close(true);
+
+?>
+Done
+--EXPECT--
+Done
+--CLEAN--
+<?php
+require_once "tester.inc";
+FPM\Tester::clean();
+?>