From 48ff654fb98dad6dd4ff7d0dd4f5fdab8dc7df3b Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Fri, 27 Nov 2020 10:51:57 +0100 Subject: [PATCH] Fixed bug #80433 Use ZEND_STRTOL to allow leading zeros in opcache.jit option. --- NEWS | 2 ++ ext/opcache/jit/zend_jit.c | 8 ++++---- ext/opcache/tests/jit/ini_leading_zero.phpt | 12 ++++++++++++ 3 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 ext/opcache/tests/jit/ini_leading_zero.phpt diff --git a/NEWS b/NEWS index dc16cf7deb..8ad31db07b 100644 --- a/NEWS +++ b/NEWS @@ -20,6 +20,8 @@ PHP NEWS . Fixed bug #80404 (Incorrect range inference result when division results in float). (Nikita) . Fixed bug #80377 (Opcache misses executor_globals). (Nikita) + . Fixed bug #80433 ( Unable to disable the use of the AVX command when using + JIT). (Nikita) - Standard: . Fixed bug #80366 (Return Value of zend_fstat() not Checked). (sagpant, cmb) diff --git a/ext/opcache/jit/zend_jit.c b/ext/opcache/jit/zend_jit.c index 32df2e41b3..9d17f17474 100644 --- a/ext/opcache/jit/zend_jit.c +++ b/ext/opcache/jit/zend_jit.c @@ -4079,8 +4079,6 @@ static int zend_jit_parse_config_num(zend_long jit) ZEND_EXT_API int zend_jit_config(zend_string *jit, int stage) { - zend_ulong num; - if (stage != ZEND_INI_STAGE_STARTUP && !JIT_G(enabled)) { if (stage == ZEND_INI_STAGE_RUNTIME) { zend_error(E_WARNING, "Cannot change opcache.jit setting at run-time (JIT is disabled)"); @@ -4118,8 +4116,10 @@ ZEND_EXT_API int zend_jit_config(zend_string *jit, int stage) JIT_G(trigger) = ZEND_JIT_ON_SCRIPT_LOAD; JIT_G(opt_flags) = ZEND_JIT_REG_ALLOC_GLOBAL | ZEND_JIT_CPU_AVX; return SUCCESS; - } else if (ZEND_HANDLE_NUMERIC(jit, num)) { - if (zend_jit_parse_config_num((zend_long)num) != SUCCESS) { + } else { + char *end; + zend_long num = ZEND_STRTOL(ZSTR_VAL(jit), &end, 10); + if (end != ZSTR_VAL(jit) + ZSTR_LEN(jit) || zend_jit_parse_config_num(num) != SUCCESS) { goto failure; } JIT_G(enabled) = 1; diff --git a/ext/opcache/tests/jit/ini_leading_zero.phpt b/ext/opcache/tests/jit/ini_leading_zero.phpt new file mode 100644 index 0000000000..5e9d38d409 --- /dev/null +++ b/ext/opcache/tests/jit/ini_leading_zero.phpt @@ -0,0 +1,12 @@ +--TEST-- +Leading zero in opcache.jit option +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.jit=0205 +--SKIPIF-- + +--FILE-- +===DONE=== +--EXPECT-- +===DONE=== -- 2.40.0