Skip to content

Commit 5317b13

Browse files
arnaud-lbsgolemon
andcommitted
Remove incorrect uses of zend_atol()
zend_atol() parses integers with size suffixes (like "128M"). Here zend_atol() is replaced with ZEND_ATOL() when the intent was not to parse a size or quantity. Co-authored-by: Sara Golemon <pollita@php.net>
1 parent 98c4a42 commit 5317b13

File tree

4 files changed

+26
-3
lines changed

4 files changed

+26
-3
lines changed

Zend/zend.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ static ZEND_INI_MH(OnUpdateAssertions) /* {{{ */
146146
{
147147
zend_long *p = (zend_long *) ZEND_INI_GET_ADDR();
148148

149-
zend_long val = zend_atol(ZSTR_VAL(new_value), ZSTR_LEN(new_value));
149+
zend_long val = ZEND_ATOL(ZSTR_VAL(new_value));
150150

151151
if (stage != ZEND_INI_STAGE_STARTUP &&
152152
stage != ZEND_INI_STAGE_SHUTDOWN &&

ext/opcache/zend_accelerator_module.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ static ZEND_INI_MH(OnUpdateJit)
165165
static ZEND_INI_MH(OnUpdateJitDebug)
166166
{
167167
zend_long *p = (zend_long *) ZEND_INI_GET_ADDR();
168-
zend_long val = zend_atol(ZSTR_VAL(new_value), ZSTR_LEN(new_value));
168+
zend_long val = ZEND_ATOL(ZSTR_VAL(new_value));
169169

170170
if (zend_jit_debug_config(*p, val, stage) == SUCCESS) {
171171
*p = val;

ext/standard/basic_functions.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2505,7 +2505,7 @@ static void php_simple_ini_parser_cb(zval *arg1, zval *arg2, zval *arg3, int cal
25052505
}
25062506

25072507
if (!(Z_STRLEN_P(arg1) > 1 && Z_STRVAL_P(arg1)[0] == '0') && is_numeric_string(Z_STRVAL_P(arg1), Z_STRLEN_P(arg1), NULL, NULL, 0) == IS_LONG) {
2508-
zend_ulong key = (zend_ulong) zend_atol(Z_STRVAL_P(arg1), Z_STRLEN_P(arg1));
2508+
zend_ulong key = (zend_ulong) ZEND_STRTOUL(Z_STRVAL_P(arg1), NULL, 0);
25092509
if ((find_hash = zend_hash_index_find(Z_ARRVAL_P(arr), key)) == NULL) {
25102510
array_init(&hash);
25112511
find_hash = zend_hash_index_add_new(Z_ARRVAL_P(arr), key, &hash);
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--TEST--
2+
parse_ini_string with numeric entry name
3+
--FILE--
4+
<?php
5+
6+
var_dump(parse_ini_string("
7+
1[]=1
8+
2M[]=2
9+
"));
10+
11+
--EXPECT--
12+
array(2) {
13+
[1]=>
14+
array(1) {
15+
[0]=>
16+
string(1) "1"
17+
}
18+
["2M"]=>
19+
array(1) {
20+
[0]=>
21+
string(1) "2"
22+
}
23+
}

0 commit comments

Comments
 (0)