[php-src] PHP-8.6: Merge branch 'PHP-8.5' into PHP-8.6

From: Date: Wed, 25 Nov 2026 17:07:16 +0000
Subject: [php-src] PHP-8.6: Merge branch 'PHP-8.5' into PHP-8.6
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-144167@lists.php.net to get a copy of this message
Author: Jorg Sowa (jorgsowa) Date: 2026-11-25T18:03:20+01:00 Commit: https://github.com/php/php-src/commit/8738d0a252ce3f78769e1c569dfd89eae5e99f52 Raw diff: https://github.com/php/php-src/commit/8738d0a252ce3f78769e1c569dfd89eae5e99f52.diff Merge branch 'PHP-8.5' into PHP-8.6 # Conflicts: # NEWS 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 aa813a76dbe1..55365b31983b 100644 --- a/NEWS +++ b/NEWS @@ -84,6 +84,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) + - Gettext: . Fixed bug GH-25584 (JIT frees the string returned by gettext(), dgettext() or dcgettext() while it is still in use). (Ilia Alshanetsky) 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(); +?>

« previous php.cvs (#144167) next »