diff options
author | Andi Gutmans <andi@php.net> | 2000-03-26 18:40:24 +0000 |
---|---|---|
committer | Andi Gutmans <andi@php.net> | 2000-03-26 18:40:24 +0000 |
commit | 7fd92b524d12d03c000ece513757a8e267013ca4 (patch) | |
tree | 1e73883966e834f1479b491a16e4c86caedddf92 /Zend/zend_builtin_functions.c | |
parent | b43f85d6419d93726ba3d60aa4b61df302572edf (diff) | |
download | php-git-7fd92b524d12d03c000ece513757a8e267013ca4.tar.gz |
- Stop zend_func_args() and co. from crashing
Diffstat (limited to 'Zend/zend_builtin_functions.c')
-rw-r--r-- | Zend/zend_builtin_functions.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index d8d826c105..1e91309e9a 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -108,9 +108,13 @@ ZEND_FUNCTION(func_num_args) int arg_count; p = EG(argument_stack).top_element-1; + if (p) { + zend_error(E_ERROR, "func_num_args(): Can't be used as a function parameter"); + } + --p; arg_count = (ulong) *p; /* this is the amount of arguments passed to func_num_args(); */ - p = EG(argument_stack).top_element-1-arg_count-1; + p = EG(argument_stack).top_element-1-arg_count-2; if (p>=EG(argument_stack).elements) { RETURN_LONG((ulong) *p); } else { @@ -135,9 +139,13 @@ ZEND_FUNCTION(func_get_arg) requested_offset = (*z_requested_offset)->value.lval; p = EG(argument_stack).top_element-1; + if (p) { + zend_error(E_ERROR, "func_get_arg(): Can't be used as a function parameter"); + } + --p; arg_count = (ulong) *p; /* this is the amount of arguments passed to func_num_args(); */ - p = EG(argument_stack).top_element-1-arg_count-1; + p = EG(argument_stack).top_element-1-arg_count-2; if (p<EG(argument_stack).elements) { zend_error(E_WARNING, "func_get_arg(): Called from the global scope - no function context"); RETURN_FALSE; @@ -162,9 +170,14 @@ ZEND_FUNCTION(func_get_args) int i; p = EG(argument_stack).top_element-1; + if (p) { + zend_error(E_ERROR, "func_get_args(): Can't be used as a function parameter"); + } + --p; + arg_count = (ulong) *p; /* this is the amount of arguments passed to func_num_args(); */ - p = EG(argument_stack).top_element-1-arg_count-1; + p = EG(argument_stack).top_element-1-arg_count-2; if (p<EG(argument_stack).elements) { zend_error(E_WARNING, "func_get_args(): Called from the global scope - no function context"); RETURN_FALSE; |