From f58a3c392f4fc0ce2f82935399c5e6e64441e2e9 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Tue, 16 Jul 2024 18:06:06 +0200 Subject: [PATCH] Fix references in request_parse_body() options array Otherwise we get funny messages like "Invalid string value in $options argument". Closes GH-14977. --- NEWS | 1 + ext/standard/http.c | 1 + .../options_array_references.phpt | 14 ++++++++++++++ 3 files changed, 16 insertions(+) create mode 100644 ext/standard/tests/http/request_parse_body/options_array_references.phpt diff --git a/NEWS b/NEWS index 6b9a3056bb3..55e8a80a1f8 100644 --- a/NEWS +++ b/NEWS @@ -25,6 +25,7 @@ PHP NEWS - Standard: . Change highlight_string() and print_r() return type to string|true. (Ayesh) + . Fix references in request_parse_body() options array. (nielsdos) - Windows: . Update the icon of the Windows executables, e.g. php.exe. (Ayesh, diff --git a/ext/standard/http.c b/ext/standard/http.c index a9e56d45161..7a4a58755d8 100644 --- a/ext/standard/http.c +++ b/ext/standard/http.c @@ -244,6 +244,7 @@ static zend_result cache_request_parse_body_option(HashTable *options, zval *opt { if (option) { zend_long result; + ZVAL_DEREF(option); if (Z_TYPE_P(option) == IS_STRING) { zend_string *errstr; result = zend_ini_parse_quantity(Z_STR_P(option), &errstr); diff --git a/ext/standard/tests/http/request_parse_body/options_array_references.phpt b/ext/standard/tests/http/request_parse_body/options_array_references.phpt new file mode 100644 index 00000000000..6c6c0c15765 --- /dev/null +++ b/ext/standard/tests/http/request_parse_body/options_array_references.phpt @@ -0,0 +1,14 @@ +--TEST-- +request_parse_body: reference in options array +--FILE-- + '128M']; +foreach ($options as $k => &$v) {} +try { + request_parse_body($options); +} catch (Throwable $e) { + echo $e->getMessage(), "\n"; +} +?> +--EXPECT-- +Request does not provide a content type