From c510083c8c9ba0f81724861112032382efe4cd77 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Wed, 22 Feb 2023 19:36:37 +0100 Subject: [PATCH] Fix incorrect string length for output_handler in zlib ini code The length of "output_handler" is supposed to be passed, but as sizeof is used, the resulting number includes the NUL character, so the length is off-by-one. Subtract one to pass the correct length. Closes GH-10667. --- NEWS | 4 ++++ ext/zlib/zlib.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 3ee934bca58..ec5a5239802 100644 --- a/NEWS +++ b/NEWS @@ -74,6 +74,10 @@ PHP NEWS 4GB. (Girgias) . Add missing error check on tidyLoadConfig. (nielsdos) +- Zlib: + . Fixed output_handler directive value's length which counted the string + terminator. (nieldos) + 14 Feb 2023, PHP 8.1.16 - Core: diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c index a53fb2acc45..9058f4a2129 100644 --- a/ext/zlib/zlib.c +++ b/ext/zlib/zlib.c @@ -1279,7 +1279,7 @@ static PHP_INI_MH(OnUpdate_zlib_output_compression) } else { int_value = zend_atoi(ZSTR_VAL(new_value), ZSTR_LEN(new_value)); } - ini_value = zend_ini_string("output_handler", sizeof("output_handler"), 0); + ini_value = zend_ini_string("output_handler", sizeof("output_handler") - 1, 0); if (ini_value && *ini_value && int_value) { php_error_docref("ref.outcontrol", E_CORE_ERROR, "Cannot use both zlib.output_compression and output_handler together!!");