[php-src] PR #25648: Fix FPM log overflow when errno text exceeds the buffer
| From: | jorgsowa | Date: | Sun, 22 Nov 2026 12:48:50 +0000 |
| Subject: | [php-src] PR #25648: Fix FPM log overflow when errno text exceeds the buffer | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-40889@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/25648
Author: jorgsowa
vzlog() formats log lines into a 2048-byte stack buffer. After appending the errno text
for ZLOG_SYSERROR messages, it checked the length returned by snprintf()
only against log_limit. With log_limit above 2048, a message nearly
filling the buffer made the length exceed it. The newline was then written past the buffer, and the
following write() sent stack memory to the log.
Truncate when the buffer size is reached too.
Reproducer:
```ini
[global]
log_limit = 4096
[www]
listen = 127.0.0.1:9000
pm = static
pm.max_children = 1
request_slowlog_timeout = 1
slowlog = /aaaa… (1970 × 'a')
```
ASAN:
```
==61448==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x00016d21b5ac
WRITE of size 1 at 0x00016d21b5ac thread T0
#0 vzlog zlog.c:248
#1 zlog_ex zlog.c:263
#2 fpm_conf_process_all_pools fpm_conf.c:1064
#3 fpm_conf_post_process fpm_conf.c:1348
#4 fpm_conf_init_main fpm_conf.c:1881
#5 fpm_init fpm.c:58
#6 main fpm_main.c:1817
This frame has 1 object(s):
[32, 2080) 'buf' (line 200) <== Memory access at offset 2092 overflows this
variable
SUMMARY: AddressSanitizer: stack-buffer-overflow zlog.c:248 in vzlog
```
Without ASAN, the log line contains 12 bytes of stack memory after the buffer.