Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: trunk/ext/standard/basic_functions.c
- ===================================================================
- --- trunk/ext/standard/basic_functions.c (revision 323122)
- +++ trunk/ext/standard/basic_functions.c (working copy)
- @@ -854,6 +854,9 @@
- ZEND_ARG_INFO(0, scanner_mode)
- ZEND_END_ARG_INFO()
- +ZEND_BEGIN_ARG_INFO(arginfo_input_vars_count, 0)
- +ZEND_END_ARG_INFO()
- +
- #if ZEND_DEBUG
- ZEND_BEGIN_ARG_INFO(arginfo_config_get_hash, 0)
- ZEND_END_ARG_INFO()
- @@ -3019,6 +3022,7 @@
- PHP_FE(is_uploaded_file, arginfo_is_uploaded_file)
- PHP_FE(move_uploaded_file, arginfo_move_uploaded_file)
- + PHP_FE(input_vars_count, arginfo_input_vars_count)
- /* functions from dns.c */
- PHP_FE(gethostbyaddr, arginfo_gethostbyaddr)
- PHP_FE(gethostbyname, arginfo_gethostbyname)
- @@ -5832,6 +5836,14 @@
- }
- /* }}} */
- +/* {{{ proto int input_vars_count(void)
- + */
- +PHP_FUNCTION(input_vars_count)
- +{
- + RETURN_LONG(PG(input_vars_count));
- +}
- +/* }}} */
- +
- /* {{{ php_simple_ini_parser_cb
- */
- static void php_simple_ini_parser_cb(zval *arg1, zval *arg2, zval *arg3, int callback_type, zval *arr TSRMLS_DC)
- Index: trunk/ext/standard/basic_functions.h
- ===================================================================
- --- trunk/ext/standard/basic_functions.h (revision 323122)
- +++ trunk/ext/standard/basic_functions.h (working copy)
- @@ -124,6 +124,8 @@
- PHP_FUNCTION(is_uploaded_file);
- PHP_FUNCTION(move_uploaded_file);
- +PHP_FUNCTION(input_vars_count);
- +
- /* From the INI parser */
- PHP_FUNCTION(parse_ini_file);
- PHP_FUNCTION(parse_ini_string);
- Index: trunk/main/php_globals.h
- ===================================================================
- --- trunk/main/php_globals.h (revision 323122)
- +++ trunk/main/php_globals.h (working copy)
- @@ -147,6 +147,7 @@
- #endif
- long max_input_nesting_level;
- long max_input_vars;
- + long input_vars_count;
- zend_bool in_user_include;
- char *user_ini_filename;
- Index: trunk/main/rfc1867.c
- ===================================================================
- --- trunk/main/rfc1867.c (revision 323122)
- +++ trunk/main/rfc1867.c (working copy)
- @@ -861,6 +861,15 @@
- }
- }
- + if (++PG(input_vars_count) > PG(max_input_vars)) {
- + if (php_rfc1867_callback != NULL) {
- + goto call_rfc1867_callback;
- + }
- + continue;
- + } else if (PG(input_vars_count) == PG(max_input_vars)) {
- + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Input variables reached %ld. To increase the limit change max_input_vars in php.ini.", PG(max_input_vars));
- + }
- +
- if (sapi_module.input_filter(PARSE_POST, param, &value, value_len, &new_val_len TSRMLS_CC)) {
- if (php_rfc1867_callback != NULL) {
- multipart_event_formdata event_formdata;
- @@ -880,14 +889,17 @@
- }
- safe_php_register_variable(param, value, new_val_len, array_ptr, 0 TSRMLS_CC);
- } else if (php_rfc1867_callback != NULL) {
- - multipart_event_formdata event_formdata;
- +call_rfc1867_callback:
- + {
- + multipart_event_formdata event_formdata;
- - event_formdata.post_bytes_processed = SG(read_post_bytes);
- - event_formdata.name = param;
- - event_formdata.value = &value;
- - event_formdata.length = value_len;
- - event_formdata.newlength = NULL;
- - php_rfc1867_callback(MULTIPART_EVENT_FORMDATA, &event_formdata, &event_extra_data TSRMLS_CC);
- + event_formdata.post_bytes_processed = SG(read_post_bytes);
- + event_formdata.name = param;
- + event_formdata.value = &value;
- + event_formdata.length = value_len;
- + event_formdata.newlength = NULL;
- + php_rfc1867_callback(MULTIPART_EVENT_FORMDATA, &event_formdata, &event_extra_data TSRMLS_CC);
- + }
- }
- if (!strcasecmp(param, "MAX_FILE_SIZE")) {
- Index: trunk/main/php_variables.c
- ===================================================================
- --- trunk/main/php_variables.c (revision 323123)
- +++ trunk/main/php_variables.c (working copy)
- @@ -77,7 +77,6 @@
- return;
- }
- -
- /* ignore leading spaces in the variable name */
- while (*var_name && *var_name==' ') {
- var_name++;
- @@ -103,7 +102,7 @@
- }
- var_len = p - var;
- - if (var_len==0) { /* empty variable name, or variable name with a space in it */
- + if (var_len == 0) { /* empty variable name, or variable name with a space in it */
- zval_dtor(val);
- free_alloca(var_orig, use_heap);
- return;
- @@ -127,7 +126,7 @@
- char *index_s;
- int new_idx_len = 0;
- - if(++nest_level > PG(max_input_nesting_level)) {
- + if (++nest_level > PG(max_input_nesting_level)) {
- HashTable *ht;
- /* too many levels of nesting */
- @@ -152,7 +151,7 @@
- if (isspace(*ip)) {
- ip++;
- }
- - if (*ip==']') {
- + if (*ip == ']') {
- index_s = NULL;
- } else {
- ip = strchr(ip, ']');
- @@ -183,18 +182,9 @@
- } else {
- if (zend_symtable_find(symtable1, 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)) {
- - if (zend_hash_num_elements(symtable1) == PG(max_input_vars)) {
- - php_error_docref(NULL TSRMLS_CC, E_WARNING, "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, index, index_len + 1, &gpc_element, sizeof(zval *), (void **) &gpc_element_p);
- - } else {
- - zval_dtor(val);
- - free_alloca(var_orig, use_heap);
- - return;
- - }
- + MAKE_STD_ZVAL(gpc_element);
- + array_init(gpc_element);
- + zend_symtable_update(symtable1, index, index_len + 1, &gpc_element, sizeof(zval *), (void **) &gpc_element_p);
- }
- }
- symtable1 = Z_ARRVAL_PP(gpc_element_p);
- @@ -231,14 +221,7 @@
- zend_symtable_exists(symtable1, index, index_len + 1)) {
- zval_ptr_dtor(&gpc_element);
- } else {
- - if (zend_hash_num_elements(symtable1) <= PG(max_input_vars)) {
- - if (zend_hash_num_elements(symtable1) == PG(max_input_vars)) {
- - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Input variables exceeded %ld. To increase the limit change max_input_vars in php.ini.", PG(max_input_vars));
- - }
- - zend_symtable_update(symtable1, index, index_len + 1, &gpc_element, sizeof(zval *), (void **) &gpc_element_p);
- - } else {
- - zval_ptr_dtor(&gpc_element);
- - }
- + zend_symtable_update(symtable1, index, index_len + 1, &gpc_element, sizeof(zval *), (void **) &gpc_element_p);
- }
- }
- }
- @@ -262,6 +245,13 @@
- if ((val = memchr(s, '=', (p - s)))) { /* have a value */
- unsigned int val_len, new_val_len;
- + if (++PG(input_vars_count) > PG(max_input_vars)) {
- + s = p + 1;
- + continue;
- + } else if (PG(input_vars_count) == PG(max_input_vars)) {
- + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Input variables reached %ld. To increase the limit change max_input_vars in php.ini.", PG(max_input_vars));
- + }
- +
- var = s;
- php_url_decode(var, (val - s));
- @@ -384,6 +374,12 @@
- }
- }
- + if (++PG(input_vars_count) > PG(max_input_vars)) {
- + goto next_cookie;
- + } else if (PG(input_vars_count) == PG(max_input_vars)) {
- + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Input variables reached %ld. To increase the limit change max_input_vars in php.ini.", PG(max_input_vars));
- + }
- +
- if (val) { /* have a value */
- int val_len;
- unsigned int new_val_len;
- Index: trunk/main/main.c
- ===================================================================
- --- trunk/main/main.c (revision 323122)
- +++ trunk/main/main.c (working copy)
- @@ -531,7 +531,7 @@
- STD_PHP_INI_ENTRY("post_max_size", "8M", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateLong, post_max_size, sapi_globals_struct,sapi_globals)
- STD_PHP_INI_ENTRY("upload_tmp_dir", NULL, PHP_INI_SYSTEM, OnUpdateStringUnempty, upload_tmp_dir, php_core_globals, core_globals)
- STD_PHP_INI_ENTRY("max_input_nesting_level", "64", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateLongGEZero, max_input_nesting_level, php_core_globals, core_globals)
- - STD_PHP_INI_ENTRY("max_input_vars", "1000", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateLongGEZero, max_input_vars, php_core_globals, core_globals)
- + STD_PHP_INI_ENTRY("max_input_vars", "4096", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateLongGEZero, max_input_vars, php_core_globals, core_globals)
- STD_PHP_INI_ENTRY("user_dir", NULL, PHP_INI_SYSTEM, OnUpdateString, user_dir, php_core_globals, core_globals)
- STD_PHP_INI_ENTRY("variables_order", "EGPCS", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateStringUnempty, variables_order, php_core_globalscore_globals)
- @@ -1806,6 +1806,8 @@
- zend_unset_timeout(TSRMLS_C);
- } zend_end_try();
- + PG(input_vars_count) = 0;
- +
- #ifdef PHP_WIN32
- if (PG(com_initialized)) {
- CoUninitialize();
Advertisement
Add Comment
Please, Sign In to add comment