diff --git a/NEWS b/NEWS index 3cdfc7969523..be1cd9c1a229 100644 --- a/NEWS +++ b/NEWS @@ -129,6 +129,8 @@ PHP NEWS . Fixed function JIT ASSIGN_DIM reporting an undefined value or key out of order, or when the VM does not, on non-array containers. (Jorg Sowa) . Fix JIT register allocation for ASSIGN to traced reference. (ndossche) + . Fixed opcache.jit_buffer_size accepting negative values, which failed + an assertion or the shared memory allocation. (Marc Bennewitz) - PDO_Firebird: . Fixed stack buffer overflow with long connection user names, passwords, diff --git a/ext/opcache/tests/jit_buffer_size_negative.phpt b/ext/opcache/tests/jit_buffer_size_negative.phpt new file mode 100644 index 000000000000..c46e6480158f --- /dev/null +++ b/ext/opcache/tests/jit_buffer_size_negative.phpt @@ -0,0 +1,17 @@ +--TEST-- +JIT: a negative opcache.jit_buffer_size is rejected +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.jit_buffer_size=-1 +--EXTENSIONS-- +opcache +--SKIPIF-- + +--FILE-- + +--EXPECT-- +Warning: Invalid "opcache.jit_buffer_size" setting. Should be greater than or equal to 0 in Unknown on line 0 +string(3) "64M" diff --git a/ext/opcache/zend_accelerator_module.c b/ext/opcache/zend_accelerator_module.c index 821dfbe39121..09d029d2dfed 100644 --- a/ext/opcache/zend_accelerator_module.c +++ b/ext/opcache/zend_accelerator_module.c @@ -220,6 +220,18 @@ static ZEND_INI_MH(OnUpdateJitDebug) return FAILURE; } +static ZEND_INI_MH(OnUpdateJitBufferSize) +{ + zend_long val = zend_ini_parse_quantity_warn(new_value, entry->name); + if (EXPECTED(val >= 0)) { + zend_long *p = (zend_long *) ZEND_INI_GET_ADDR(); + *p = val; + return SUCCESS; + } + zend_error(E_WARNING, "Invalid \"%s\" setting. Should be greater than or equal to 0", ZSTR_VAL(entry->name)); + return FAILURE; +} + static ZEND_INI_MH(OnUpdateCounter) { zend_long val = zend_ini_parse_quantity_warn(new_value, entry->name); @@ -343,7 +355,7 @@ ZEND_INI_BEGIN() #endif #ifdef HAVE_JIT STD_PHP_INI_ENTRY("opcache.jit" , "disable", PHP_INI_ALL, OnUpdateJit, options, zend_jit_globals, jit_globals) - STD_PHP_INI_ENTRY("opcache.jit_buffer_size" , ZEND_JIT_DEFAULT_BUFFER_SIZE, PHP_INI_SYSTEM, OnUpdateLong, buffer_size, zend_jit_globals, jit_globals) + STD_PHP_INI_ENTRY("opcache.jit_buffer_size" , ZEND_JIT_DEFAULT_BUFFER_SIZE, PHP_INI_SYSTEM, OnUpdateJitBufferSize, buffer_size, zend_jit_globals, jit_globals) STD_PHP_INI_ENTRY("opcache.jit_debug" , "0", PHP_INI_ALL, OnUpdateJitDebug, debug, zend_jit_globals, jit_globals) STD_PHP_INI_ENTRY("opcache.jit_bisect_limit" , "0", PHP_INI_ALL, OnUpdateLong, bisect_limit, zend_jit_globals, jit_globals) STD_PHP_INI_ENTRY("opcache.jit_prof_threshold" , "0.005", PHP_INI_ALL, OnUpdateReal, prof_threshold, zend_jit_globals, jit_globals)