Skip to content

Commit a1de3e8

Browse files
committed
Merge branch 'PHP-7.4'
* PHP-7.4: Update changelogs Fix bug #62397 - disable_functions does not work with eval.
2 parents e04c41f + c27b531 commit a1de3e8

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
@@ -2642,6 +2642,12 @@ ZEND_API int zend_set_hash_symbol(zval *symbol, const char *name, int name_lengt
26422642

26432643
/* Disabled functions support */
26442644

2645+
zend_op_array *display_disabled_compile_string(zval *source_string, char *filename)
2646+
{
2647+
zend_error(E_WARNING, "eval() has been disabled for security reasons");
2648+
return NULL;
2649+
}
2650+
26452651
/* {{{ proto void display_disabled_function(void)
26462652
Dummy function which displays an error when a disabled function is called. */
26472653
ZEND_API ZEND_FUNCTION(display_disabled_function)
@@ -2653,6 +2659,12 @@ ZEND_API ZEND_FUNCTION(display_disabled_function)
26532659
ZEND_API int zend_disable_function(char *function_name, size_t function_name_length) /* {{{ */
26542660
{
26552661
zend_internal_function *func;
2662+
2663+
if (strcmp(function_name, "eval") == 0) {
2664+
zend_compile_string = display_disabled_compile_string;
2665+
return SUCCESS;
2666+
}
2667+
26562668
if ((func = zend_hash_str_find_ptr(CG(function_table), function_name, function_name_length))) {
26572669
func->fn_flags &= ~(ZEND_ACC_VARIADIC | ZEND_ACC_HAS_TYPE_HINTS);
26582670
func->num_args = 0;

0 commit comments

Comments
 (0)