From ee0e6963f39cc8f30bbd5675a0c4880a18b63b00 Mon Sep 17 00:00:00 2001 From: Manuel Mausz Date: Fri, 9 Jun 2017 01:43:08 +0200 Subject: [PATCH 1/2] Fixed bug #74600 Make sure the hash entry is an array. The origin fix broke support for HOST/PATH ini sections. Only the beginning of the string has to match. Revert this check but use zend_binary_strncasecmp instead of strncasecmp. --- main/php_ini.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/main/php_ini.c b/main/php_ini.c index 7d09fbcfad2..cf9711fd67f 100644 --- a/main/php_ini.c +++ b/main/php_ini.c @@ -280,7 +280,7 @@ static void php_ini_parser_cb(zval *arg1, zval *arg2, zval *arg3, int callback_t size_t key_len; /* PATH sections */ - if (zend_string_equals_literal_ci(Z_STR_P(arg1), "PATH")) { + if (!zend_binary_strncasecmp(Z_STRVAL_P(arg1), Z_STRLEN_P(arg1), "PATH", sizeof("PATH") - 1, sizeof("PATH") - 1)) { key = Z_STRVAL_P(arg1); key = key + sizeof("PATH") - 1; key_len = Z_STRLEN_P(arg1) - sizeof("PATH") + 1; @@ -291,7 +291,7 @@ static void php_ini_parser_cb(zval *arg1, zval *arg2, zval *arg3, int callback_t TRANSLATE_SLASHES_LOWER(key); /* HOST sections */ - } else if (zend_string_equals_literal_ci(Z_STR_P(arg1), "HOST")) { + } else if (!zend_binary_strncasecmp(Z_STRVAL_P(arg1), Z_STRLEN_P(arg1), "HOST", sizeof("HOST") - 1, sizeof("HOST") - 1)) { key = Z_STRVAL_P(arg1); key = key + sizeof("HOST") - 1; key_len = Z_STRLEN_P(arg1) - sizeof("HOST") + 1; @@ -328,7 +328,9 @@ static void php_ini_parser_cb(zval *arg1, zval *arg2, zval *arg3, int callback_t zend_hash_init(Z_ARRVAL(section_arr), 8, NULL, (dtor_func_t) config_zval_dtor, 1); entry = zend_hash_str_update(target_hash, key, key_len, §ion_arr); } - active_ini_hash = Z_ARRVAL_P(entry); + if (Z_TYPE_P(entry) == IS_ARRAY) { + active_ini_hash = Z_ARRVAL_P(entry); + } } } break; From 91f129ebf7919bdbd79c621cc4b2211d06d05685 Mon Sep 17 00:00:00 2001 From: Manuel Mausz Date: Fri, 9 Jun 2017 23:28:19 +0200 Subject: [PATCH 2/2] Add simple cli test for PATH/HOST ini sections --- sapi/cli/tests/023.phpt | 46 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 sapi/cli/tests/023.phpt diff --git a/sapi/cli/tests/023.phpt b/sapi/cli/tests/023.phpt new file mode 100644 index 00000000000..91674e321e6 --- /dev/null +++ b/sapi/cli/tests/023.phpt @@ -0,0 +1,46 @@ +--TEST-- +HOST/PATH ini sections test for cli +--SKIPIF-- + +--FILE-- + array("pipe", "r"), + 1 => array("pipe", "w"), + 2 => array("pipe", "w"), +); +$pipes = array(); +$proc = proc_open("$php -c $ini_file -r 'echo ini_get(\"memory_limit\");'", $desc, $pipes); +if (!$proc) { + exit(1); +} +var_dump(stream_get_contents($pipes[1])); +var_dump(stream_get_contents($pipes[2])); + +proc_terminate($proc); +proc_close($proc); +?> +--CLEAN-- + +--EXPECTF-- +string(3) "40M" +string(0) ""