From 989205e95cde4c43b562148a5f35fe32bb7af3da Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Mon, 12 Jul 2021 16:56:00 +0200 Subject: [PATCH] Remove incorrect uses of zend_atoi() zend_atoi() parses integers with size suffixes (like "128M"). These just want to use a plain number, so use ZEND_ATOL instead. --- Zend/zend.c | 2 +- Zend/zend_alloc.c | 6 +++--- ext/session/session.c | 3 +-- sapi/cli/php_cli.c | 2 +- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Zend/zend.c b/Zend/zend.c index 5737f5ea373..8091341390e 100644 --- a/Zend/zend.c +++ b/Zend/zend.c @@ -896,7 +896,7 @@ void zend_startup(zend_utility_functions *utility_functions) /* {{{ */ { char *tmp = getenv("USE_ZEND_DTRACE"); - if (tmp && zend_atoi(tmp, 0)) { + if (tmp && ZEND_ATOL(tmp)) { zend_dtrace_enabled = 1; zend_compile_file = dtrace_compile_file; zend_execute_ex = dtrace_execute_ex; diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c index 38608d0f15a..558221d5d48 100644 --- a/Zend/zend_alloc.c +++ b/Zend/zend_alloc.c @@ -2801,8 +2801,8 @@ static void alloc_globals_ctor(zend_alloc_globals *alloc_globals) #if ZEND_MM_CUSTOM tmp = getenv("USE_ZEND_ALLOC"); - if (tmp && !zend_atoi(tmp, 0)) { - bool tracked = (tmp = getenv("USE_TRACKED_ALLOC")) && zend_atoi(tmp, 0); + if (tmp && ZEND_ATOL(tmp)) { + bool tracked = (tmp = getenv("USE_TRACKED_ALLOC")) && ZEND_ATOL(tmp); zend_mm_heap *mm_heap = alloc_globals->mm_heap = malloc(sizeof(zend_mm_heap)); memset(mm_heap, 0, sizeof(zend_mm_heap)); mm_heap->use_custom_heap = ZEND_MM_CUSTOM_HEAP_STD; @@ -2827,7 +2827,7 @@ static void alloc_globals_ctor(zend_alloc_globals *alloc_globals) #endif tmp = getenv("USE_ZEND_ALLOC_HUGE_PAGES"); - if (tmp && zend_atoi(tmp, 0)) { + if (tmp && ZEND_ATOL(tmp)) { zend_mm_use_huge_pages = 1; } alloc_globals->mm_heap = zend_mm_init(); diff --git a/ext/session/session.c b/ext/session/session.c index c096e809c17..18444932ceb 100644 --- a/ext/session/session.c +++ b/ext/session/session.c @@ -769,8 +769,7 @@ static PHP_INI_MH(OnUpdateLazyWrite) /* {{{ */ static PHP_INI_MH(OnUpdateRfc1867Freq) /* {{{ */ { - int tmp; - tmp = zend_atoi(ZSTR_VAL(new_value), ZSTR_LEN(new_value)); + int tmp = ZEND_ATOL(ZSTR_VAL(new_value)); if(tmp < 0) { php_error_docref(NULL, E_WARNING, "session.upload_progress.freq must be greater than or equal to 0"); return FAILURE; diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c index 2a285d43657..1c408ab2711 100644 --- a/sapi/cli/php_cli.c +++ b/sapi/cli/php_cli.c @@ -1196,7 +1196,7 @@ int main(int argc, char *argv[]) #if defined(PHP_WIN32) && defined(_DEBUG) { char *tmp = getenv("PHP_WIN32_DEBUG_HEAP"); - if (tmp && zend_atoi(tmp, 0)) { + if (tmp && ZEND_ATOL(tmp, 0)) { int tmp_flag; _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE); _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);