summaryrefslogtreecommitdiff
path: root/ext/standard/basic_functions.c
diff options
context:
space:
mode:
authorAntony Dovgal <tony2001@php.net>2007-05-22 14:32:40 +0000
committerAntony Dovgal <tony2001@php.net>2007-05-22 14:32:40 +0000
commitf996452e8ba67e5a241202b6a743df9c136706a3 (patch)
tree679714b18ffba0c0813927ce473502fbafb2971b /ext/standard/basic_functions.c
parent69c40e4141c603e8f34fa1d7e56f5a429d69fbc4 (diff)
downloadphp-git-f996452e8ba67e5a241202b6a743df9c136706a3.tar.gz
improve variable name checks
add more tests
Diffstat (limited to 'ext/standard/basic_functions.c')
-rw-r--r--ext/standard/basic_functions.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c
index 0cbb06db7b..0d42473bdf 100644
--- a/ext/standard/basic_functions.c
+++ b/ext/standard/basic_functions.c
@@ -6321,16 +6321,10 @@ static int copy_request_variable(void *pDest, int num_args, va_list args, zend_h
prefix = va_arg(args, zval *);
prefix_len = Z_UNILEN_P(prefix);
- if (!prefix_len) {
- if (!hash_key->nKeyLength) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Numeric key detected - possible security hazard");
- return 0;
- } else if (hash_key->nKeyLength == sizeof("GLOBALS") &&
- ZEND_U_EQUAL(hash_key->type, hash_key->arKey, hash_key->nKeyLength-1, "GLOBALS", sizeof("GLOBALS")-1)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attempted GLOBALS variable overwrite");
- return 0;
- }
- }
+ if (!prefix_len && !hash_key->nKeyLength) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Numeric key detected - possible security hazard");
+ return 0;
+ }
if (hash_key->nKeyLength) {
php_prefix_varname(&new_key, prefix, hash_key->arKey, hash_key->nKeyLength-1, hash_key->type, 0 TSRMLS_CC);
@@ -6342,6 +6336,11 @@ static int copy_request_variable(void *pDest, int num_args, va_list args, zend_h
zval_dtor(&num);
}
+ if (php_varname_check(Z_TYPE(new_key), Z_UNIVAL(new_key), Z_UNILEN(new_key), 0 TSRMLS_CC) == FAILURE) {
+ zval_dtor(&new_key);
+ return 0;
+ }
+
zend_u_delete_global_variable(Z_TYPE(new_key), Z_UNIVAL(new_key), Z_UNILEN(new_key) TSRMLS_CC);
ZEND_U_SET_SYMBOL_WITH_LENGTH(&EG(symbol_table), Z_TYPE(new_key), Z_UNIVAL(new_key), Z_UNILEN(new_key) + 1, *var, (*var)->refcount+1, 0);