diff options
Diffstat (limited to 'main/php_variables.c')
-rw-r--r-- | main/php_variables.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/main/php_variables.c b/main/php_variables.c index d3cfb7f737..c56d23003c 100644 --- a/main/php_variables.c +++ b/main/php_variables.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2017 The PHP Group | + | Copyright (c) 1997-2018 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -79,7 +79,7 @@ PHPAPI void php_register_variable_ex(char *var_name, zval *val, zval *track_vars /* ignore leading spaces in the variable name */ - while (*var_name && *var_name==' ') { + while (*var_name==' ') { var_name++; } @@ -109,6 +109,26 @@ PHPAPI void php_register_variable_ex(char *var_name, zval *val, zval *track_vars return; } + if (var_len == sizeof("this")-1 && EG(current_execute_data)) { + zend_execute_data *ex = EG(current_execute_data); + + while (ex) { + if (ex->func && ZEND_USER_CODE(ex->func->common.type)) { + if ((ZEND_CALL_INFO(ex) & ZEND_CALL_HAS_SYMBOL_TABLE) + && ex->symbol_table == symtable1) { + if (memcmp(var, "this", sizeof("this")-1) == 0) { + zend_throw_error(NULL, "Cannot re-assign $this"); + zval_dtor(val); + free_alloca(var_orig, use_heap); + return; + } + } + break; + } + ex = ex->prev_execute_data; + } + } + /* GLOBALS hijack attempt, reject parameter */ if (symtable1 == &EG(symbol_table) && var_len == sizeof("GLOBALS")-1 && |