-
Notifications
You must be signed in to change notification settings - Fork 8k
Fix bug #62397 - disable_functions does not work with eval. #4084
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--TEST-- | ||
errmsg: disabled eval function | ||
--INI-- | ||
disable_functions=eval | ||
--FILE-- | ||
<?php | ||
|
||
eval('echo "Eval";'); | ||
|
||
echo "Done\n"; | ||
?> | ||
--EXPECTF-- | ||
Warning: eval() has been disabled for security reasons in %s on line %d | ||
Done |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2751,6 +2751,12 @@ ZEND_API int zend_set_hash_symbol(zval *symbol, const char *name, int name_lengt | |
|
||
/* Disabled functions support */ | ||
|
||
zend_op_array *display_disabled_compile_string(zval *source_string, char *filename) | ||
{ | ||
zend_error(E_WARNING, "eval() has been disabled for security reasons"); | ||
return NULL; | ||
} | ||
|
||
/* {{{ proto void display_disabled_function(void) | ||
Dummy function which displays an error when a disabled function is called. */ | ||
ZEND_API ZEND_FUNCTION(display_disabled_function) | ||
|
@@ -2762,6 +2768,12 @@ ZEND_API ZEND_FUNCTION(display_disabled_function) | |
ZEND_API int zend_disable_function(char *function_name, size_t function_name_length) /* {{{ */ | ||
{ | ||
zend_internal_function *func; | ||
|
||
if (strcmp(function_name, "eval") == 0) { | ||
zend_compile_string = display_disabled_compile_string; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a terrible idea. It makes Xdebug not being able to change variables, or allow for watches either, if eval is turned off this way. Xdebug uses |
||
return SUCCESS; | ||
} | ||
|
||
if ((func = zend_hash_str_find_ptr(CG(function_table), function_name, function_name_length))) { | ||
func->fn_flags &= ~(ZEND_ACC_VARIADIC | ZEND_ACC_HAS_TYPE_HINTS); | ||
func->num_args = 0; | ||
|
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The added
display_disabled_compile_string
function is because we can't use this one?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the signatures are different.
display_disabled_function
has the signature of an internal function and it can be replaced as function pointer in thefunction_table
(seezend_disable_function
just below this code in the same file).The
eval
disable support makes use of the function pointer tozend_compile_string
which can be replaced with different implementation using the same idea as the function table disable functionality.