From bafccc7dbf3170380a788399205771ffab26afbb Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Mon, 10 Nov 2003 04:12:50 +0000 Subject: [PATCH] MFH: Fixed bug #26176 (Fixed handling of numeric keys in INI files). --- NEWS | 1 + ext/standard/basic_functions.c | 26 +++++++++++++++++++------- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/NEWS b/NEWS index 6a40a36dda..af5d7f4556 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,7 @@ PHP 4 NEWS ?? ??? 2003, Version 4.3.5 - Fixed header handler in NSAPI SAPI module (header->replace was ignored, send_default_content_type now sends value from php.ini). (Uwe Schindler) +- Fixed bug #26176 (Fixed handling of numeric keys in INI files). (Ilia) - Fixed bug #26148 (Print the notice before modifying variable on type mismatch). (morten-bugs dot php dot net at afdelingp dot dk, Ilia) - Fixed bug #26128 (mbstring prints out wrong information on phpinfo()). diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 6725f8fc1a..2bcd5e6c42 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -2789,7 +2789,12 @@ static void php_simple_ini_parser_cb(zval *arg1, zval *arg2, int callback_type, *element = *arg2; zval_copy_ctor(element); INIT_PZVAL(element); - zend_hash_update(Z_ARRVAL_P(arr), Z_STRVAL_P(arg1), Z_STRLEN_P(arg1)+1, &element, sizeof(zval *), NULL); + if (is_numeric_string(Z_STRVAL_P(arg1), Z_STRLEN_P(arg1), NULL, NULL, 0) != IS_LONG) { + zend_hash_update(Z_ARRVAL_P(arr), Z_STRVAL_P(arg1), Z_STRLEN_P(arg1)+1, &element, sizeof(zval *), NULL); + } else { + ulong key = (ulong) zend_atoi(Z_STRVAL_P(arg1), Z_STRLEN_P(arg1)); + zend_hash_index_update(Z_ARRVAL_P(arr), key, &element, sizeof(zval *), NULL); + } break; case ZEND_INI_PARSER_SECTION: @@ -2822,20 +2827,27 @@ static void php_ini_parser_cb_with_sections(zval *arg1, zval *arg2, int callback *element = *arg2; zval_copy_ctor(element); INIT_PZVAL(element); - zend_hash_update(Z_ARRVAL_P(active_arr), Z_STRVAL_P(arg1), + if (is_numeric_string(Z_STRVAL_P(arg1), Z_STRLEN_P(arg1), NULL, NULL, 0) != IS_LONG) { + zend_hash_update(Z_ARRVAL_P(active_arr), Z_STRVAL_P(arg1), Z_STRLEN_P(arg1)+1, &element, sizeof(zval *), NULL); + } else { + ulong key = (ulong) zend_atoi(Z_STRVAL_P(arg1), Z_STRLEN_P(arg1)); + zend_hash_index_update(Z_ARRVAL_P(active_arr), key, &element, sizeof(zval *), NULL); + } } break; case ZEND_INI_PARSER_SECTION: MAKE_STD_ZVAL(BG(active_ini_file_section)); array_init(BG(active_ini_file_section)); - zend_hash_update( Z_ARRVAL_P(arr), - Z_STRVAL_P(arg1), - Z_STRLEN_P(arg1)+1, - &BG(active_ini_file_section), - sizeof(zval *), NULL); + if (is_numeric_string(Z_STRVAL_P(arg1), Z_STRLEN_P(arg1), NULL, NULL, 0) != IS_LONG) { + zend_hash_update(Z_ARRVAL_P(arr), Z_STRVAL_P(arg1), Z_STRLEN_P(arg1)+1, + &BG(active_ini_file_section), sizeof(zval *), NULL); + } else { + ulong key = (ulong) zend_atoi(Z_STRVAL_P(arg1), Z_STRLEN_P(arg1)); + zend_hash_index_update(Z_ARRVAL_P(arr), key, &BG(active_ini_file_section), sizeof(zval *), NULL); + } break; } } -- 2.40.0