Skip to content

Commit 050d299

Browse files
beberleipetk
authored andcommitted
Fix bug #62397 - disable_functions does not work with eval.
1 parent f1a5350 commit 050d299

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

Zend/tests/errmsg_046.phpt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
errmsg: disabled eval function
3+
--INI--
4+
disable_functions=eval
5+
--FILE--
6+
<?php
7+
8+
eval('echo "Eval";');
9+
10+
echo "Done\n";
11+
?>
12+
--EXPECTF--
13+
Warning: eval() has been disabled for security reasons in %s on line %d
14+
Done

Zend/zend_API.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2757,6 +2757,12 @@ ZEND_API int zend_set_hash_symbol(zval *symbol, const char *name, int name_lengt
27572757

27582758
/* Disabled functions support */
27592759

2760+
zend_op_array *display_disabled_compile_string(zval *source_string, char *filename)
2761+
{
2762+
zend_error(E_WARNING, "eval() has been disabled for security reasons");
2763+
return NULL;
2764+
}
2765+
27602766
/* {{{ proto void display_disabled_function(void)
27612767
Dummy function which displays an error when a disabled function is called. */
27622768
ZEND_API ZEND_FUNCTION(display_disabled_function)
@@ -2768,6 +2774,12 @@ ZEND_API ZEND_FUNCTION(display_disabled_function)
27682774
ZEND_API int zend_disable_function(char *function_name, size_t function_name_length) /* {{{ */
27692775
{
27702776
zend_internal_function *func;
2777+
2778+
if (strcmp(function_name, "eval") == 0) {
2779+
zend_compile_string = display_disabled_compile_string;
2780+
return SUCCESS;
2781+
}
2782+
27712783
if ((func = zend_hash_str_find_ptr(CG(function_table), function_name, function_name_length))) {
27722784
func->fn_flags &= ~(ZEND_ACC_VARIADIC | ZEND_ACC_HAS_TYPE_HINTS);
27732785
func->num_args = 0;

0 commit comments

Comments
 (0)