Skip to content

Commit 8738d0a

Browse files
committed
Merge branch 'PHP-8.5' into PHP-8.6
# Conflicts: # NEWS
2 parents c112f0f + ab85c50 commit 8738d0a

3 files changed

Lines changed: 43 additions & 1 deletion

File tree

‎NEWS‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ PHP NEWS
8484
. Fixed stack overflow in filter_var() and filter_var_array() with deeply
8585
nested arrays. (Eyüp Can Akman)
8686

87+
- FPM:
88+
. Fixed stack buffer overflow when logging an error with errno text and
89+
log_limit above 2048. (Jorg Sowa)
90+
8791
- Gettext:
8892
. Fixed bug GH-25584 (JIT frees the string returned by gettext(),
8993
dgettext() or dcgettext() while it is still in use). (Ilia Alshanetsky)

‎sapi/fpm/fpm/zlog.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ void vzlog(const char *function, int line, int flags, const char *fmt, va_list a
227227
if (flags & ZLOG_HAVE_ERRNO) {
228228
len += snprintf(buf + len, buf_size - len,
229229
": %s (%d)", strerror(saved_errno), saved_errno);
230-
if (len >= zlog_limit) {
230+
if (len >= zlog_limit || len >= buf_size) {
231231
truncated = 1;
232232
}
233233
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
--TEST--
2+
FPM: Log message with errno is truncated to the buffer when log_limit is above it
3+
--SKIPIF--
4+
<?php include "skipif.inc"; ?>
5+
--FILE--
6+
<?php
7+
8+
require_once "tester.inc";
9+
10+
/* The error line nearly fills the 2048-byte log buffer before errno text is appended. */
11+
$slowlog = '/' . str_repeat('a', 1970);
12+
13+
$cfg = <<<EOT
14+
[global]
15+
error_log = {{FILE:LOG}}
16+
log_limit = 4096
17+
[unconfined]
18+
listen = {{ADDR}}
19+
pm = static
20+
pm.max_children = 1
21+
request_slowlog_timeout = 1
22+
slowlog = $slowlog
23+
EOT;
24+
25+
$tester = new FPM\Tester($cfg);
26+
$tester->start();
27+
$tester->expectLogPattern('/^\[[^\]]+\] ERROR: Unable to create or open slowlog\(\/a{1970}\): .{7}\.\.\.$/');
28+
$tester->close(true);
29+
30+
?>
31+
Done
32+
--EXPECT--
33+
Done
34+
--CLEAN--
35+
<?php
36+
require_once "tester.inc";
37+
FPM\Tester::clean();
38+
?>

0 commit comments

Comments
 (0)