Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,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 use-after-free when drawing with a brush or tile image that was
released after imagesetbrush() or imagesettile(). (lacatoire)
Expand Down
2 changes: 1 addition & 1 deletion sapi/fpm/fpm/zlog.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
38 changes: 38 additions & 0 deletions sapi/fpm/tests/log-limit-above-buffer-errno-msg.phpt
Original file line number Diff line number Diff line change
@@ -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();
?>
Loading