summaryrefslogtreecommitdiff
path: root/main/php_variables.c
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@php.net>2011-12-14 08:56:35 +0000
committerDmitry Stogov <dmitry@php.net>2011-12-14 08:56:35 +0000
commit6fb3897f8052d29d46e73a8f666acc027a384615 (patch)
tree49da7e0c5b31451104a01faf5fcec12e39041fd8 /main/php_variables.c
parentf94cc91dda4b12250c3e590457c459ab8c82f0d8 (diff)
downloadphp-git-6fb3897f8052d29d46e73a8f666acc027a384615.tar.gz
Added max_input_vars directive to prevent attacks based on hash collisions
Diffstat (limited to 'main/php_variables.c')
-rw-r--r--main/php_variables.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/main/php_variables.c b/main/php_variables.c
index cfb2380210..976e9d5066 100644
--- a/main/php_variables.c
+++ b/main/php_variables.c
@@ -179,6 +179,9 @@ PHPAPI void php_register_variable_ex(char *var_name, zval *val, zval *track_vars
escaped_index = index;
if (zend_symtable_find(symtable1, escaped_index, index_len + 1, (void **) &gpc_element_p) == FAILURE
|| Z_TYPE_PP(gpc_element_p) != IS_ARRAY) {
+ if (zend_hash_num_elements(symtable1) >= PG(max_input_vars)) {
+ php_error_docref(NULL TSRMLS_CC, E_ERROR, "Input variables exceeded %ld. To increase the limit change max_input_vars in php.ini.", PG(max_input_vars));
+ }
MAKE_STD_ZVAL(gpc_element);
array_init(gpc_element);
zend_symtable_update(symtable1, escaped_index, index_len + 1, &gpc_element, sizeof(zval *), (void **) &gpc_element_p);
@@ -220,6 +223,9 @@ plain_var:
zend_symtable_exists(symtable1, escaped_index, index_len + 1)) {
zval_ptr_dtor(&gpc_element);
} else {
+ if (zend_hash_num_elements(symtable1) >= PG(max_input_vars)) {
+ php_error_docref(NULL TSRMLS_CC, E_ERROR, "Input variables exceeded %ld. To increase the limit change max_input_vars in php.ini.", PG(max_input_vars));
+ }
zend_symtable_update(symtable1, escaped_index, index_len + 1, &gpc_element, sizeof(zval *), (void **) &gpc_element_p);
}
if (escaped_index != index) {