Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
17 changes: 17 additions & 0 deletions ext/opcache/tests/jit_buffer_size_negative.phpt
Original file line number Diff line number Diff line change
@@ -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--
<?php if (ini_get('opcache.jit_buffer_size') === false) die('skip JIT is not built'); ?>
--FILE--
<?php
var_dump(ini_get('opcache.jit_buffer_size'));
?>
--EXPECT--
Warning: Invalid "opcache.jit_buffer_size" setting. Should be greater than or equal to 0 in Unknown on line 0
string(3) "64M"
14 changes: 13 additions & 1 deletion ext/opcache/zend_accelerator_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down