Skip to content

Commit ef4f6a3

Browse files
committed
Use ZEND_STRTOL instead of zend_atol()
zend_ato[il]() don't *just* do number parsing. They also check for a 'K', 'M', or 'G' at the end of the string, and multiply the parsed value out accordingly. None of these use cases actually call for this behavior, so invoke ZEND_STRTOL() separately.
1 parent fc42ac2 commit ef4f6a3

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

Zend/zend.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ static ZEND_INI_MH(OnUpdateAssertions) /* {{{ */
149149

150150
p = (zend_long *) (base+(size_t) mh_arg1);
151151

152-
val = zend_atol(ZSTR_VAL(new_value), ZSTR_LEN(new_value));
152+
val = ZEND_STRTOL(ZSTR_VAL(new_value), NULL, 0);
153153

154154
if (stage != ZEND_INI_STAGE_STARTUP &&
155155
stage != ZEND_INI_STAGE_SHUTDOWN &&
@@ -828,7 +828,7 @@ int zend_startup(zend_utility_functions *utility_functions) /* {{{ */
828828
{
829829
char *tmp = getenv("USE_ZEND_DTRACE");
830830

831-
if (tmp && zend_atoi(tmp, 0)) {
831+
if (tmp && ZEND_STRTOL(tmp, NULL, 0)) {
832832
zend_dtrace_enabled = 1;
833833
zend_compile_file = dtrace_compile_file;
834834
zend_execute_ex = dtrace_execute_ex;

Zend/zend_alloc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2705,7 +2705,7 @@ static void alloc_globals_ctor(zend_alloc_globals *alloc_globals)
27052705

27062706
#if ZEND_MM_CUSTOM
27072707
tmp = getenv("USE_ZEND_ALLOC");
2708-
if (tmp && !zend_atoi(tmp, 0)) {
2708+
if (tmp && !ZEND_STRTOL(tmp, NULL, 0)) {
27092709
alloc_globals->mm_heap = malloc(sizeof(zend_mm_heap));
27102710
memset(alloc_globals->mm_heap, 0, sizeof(zend_mm_heap));
27112711
alloc_globals->mm_heap->use_custom_heap = ZEND_MM_CUSTOM_HEAP_STD;
@@ -2717,7 +2717,7 @@ static void alloc_globals_ctor(zend_alloc_globals *alloc_globals)
27172717
#endif
27182718

27192719
tmp = getenv("USE_ZEND_ALLOC_HUGE_PAGES");
2720-
if (tmp && zend_atoi(tmp, 0)) {
2720+
if (tmp && ZEND_STRTOL(tmp, NULL, 0)) {
27212721
zend_mm_use_huge_pages = 1;
27222722
}
27232723
alloc_globals->mm_heap = zend_mm_init();

ext/session/session.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -768,8 +768,8 @@ static PHP_INI_MH(OnUpdateLazyWrite) /* {{{ */
768768

769769
static PHP_INI_MH(OnUpdateRfc1867Freq) /* {{{ */
770770
{
771-
int tmp;
772-
tmp = zend_atoi(ZSTR_VAL(new_value), ZSTR_LEN(new_value));
771+
zend_long tmp = ZEND_STRTOL(ZSTR_VAL(new_value), NULL, 0);
772+
773773
if(tmp < 0) {
774774
php_error_docref(NULL, E_WARNING, "session.upload_progress.freq must be greater than or equal to zero");
775775
return FAILURE;

ext/standard/basic_functions.c

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

59965996
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) {
5997-
zend_ulong key = (zend_ulong) zend_atol(Z_STRVAL_P(arg1), Z_STRLEN_P(arg1));
5997+
zend_ulong key = ZEND_STRTOUL(Z_STRVAL_P(arg1), NULL, 0);
59985998
if ((find_hash = zend_hash_index_find(Z_ARRVAL_P(arr), key)) == NULL) {
59995999
array_init(&hash);
60006000
find_hash = zend_hash_index_add_new(Z_ARRVAL_P(arr), key, &hash);

ext/zlib/zlib.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1436,7 +1436,7 @@ static PHP_INI_MH(OnUpdate_zlib_output_compression)
14361436
} else if (!strncasecmp(ZSTR_VAL(new_value), "on", sizeof("on"))) {
14371437
int_value = 1;
14381438
} else {
1439-
int_value = zend_atoi(ZSTR_VAL(new_value), ZSTR_LEN(new_value));
1439+
int_value = ZEND_STRTOL(ZSTR_VAL(new_value), NULL, 0);
14401440
}
14411441
ini_value = zend_ini_string("output_handler", sizeof("output_handler"), 0);
14421442

0 commit comments

Comments
 (0)