Skip to content

Commit ab85c50

Browse files
committed
Merge branch 'PHP-8.4' into PHP-8.5
2 parents 7df3695 + 0ccf33a commit ab85c50

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
@@ -65,6 +65,10 @@ PHP NEWS
6565
. Fixed stack overflow in filter_var() and filter_var_array() with deeply
6666
nested arrays. (Eyüp Can Akman)
6767

68+
- FPM:
69+
. Fixed stack buffer overflow when logging an error with errno text and
70+
log_limit above 2048. (Jorg Sowa)
71+
6872
- GD:
6973
. Fixed imagecreatefromstring() continuing to decode after throwing for a
7074
string longer than INT_MAX. (lacatoire)

‎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)