Skip to content

Commit 7fcbe4d

Browse files
committed
Fixed bug #63447 (max_input_vars doesn't filter variables when mbstring.encoding_translation = On)
1 parent 0ee5d18 commit 7fcbe4d

File tree

5 files changed

+84
-0
lines changed

5 files changed

+84
-0
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ PHP NEWS
1212
. Fixed bug #63389 (Missing context check on libxml_set_streams_context()
1313
causes memleak). (Laruence)
1414

15+
- Mbstring:
16+
. Fixed bug #63447 (max_input_vars doesn't filter variables when
17+
mbstring.encoding_translation = On). (Laruence)
18+
1519
- MySQL:
1620
. Fixed compilation failure on mixed 32/64 bit systems. (Andrey)
1721

ext/mbstring/mb_gpc.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,12 @@ enum mbfl_no_encoding _php_mb_encoding_handler_ex(const php_mb_encoding_handler_
262262
n++;
263263
var = php_strtok_r(NULL, info->separator, &strtok_buf);
264264
}
265+
266+
if (n > (PG(max_input_vars) * 2)) {
267+
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));
268+
goto out;
269+
}
270+
265271
num = n; /* make sure to process initilized vars only */
266272

267273
/* initialize converter */

ext/mbstring/tests/bug63447_001.phpt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
Bug #63447 (max_input_vars doesn't filter variables when mbstring.encoding_translation = On)
3+
--SKIPIF--
4+
<?php
5+
extension_loaded('mbstring') or die('skip');
6+
?>
7+
--INI--
8+
max_input_nesting_level=10
9+
max_input_vars=5
10+
mbstring.encoding_translation=1
11+
--POST--
12+
a=1&b=2&c=3&d=4&e=5&f=6
13+
--FILE--
14+
<?php
15+
var_dump($_POST);
16+
?>
17+
--EXPECT--
18+
Warning: Unknown: Input variables exceeded 5. To increase the limit change max_input_vars in php.ini. in Unknown on line 0
19+
array(0) {
20+
}

ext/mbstring/tests/bug63447_002.phpt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
Bug #63447 (max_input_vars doesn't filter variables when mbstring.encoding_translation = On)
3+
--SKIPIF--
4+
<?php
5+
extension_loaded('mbstring') or die('skip');
6+
?>
7+
--INI--
8+
max_input_nesting_level=10
9+
max_input_vars=4
10+
mbstring.encoding_translation=1
11+
--POST--
12+
a=1&b=2&c=3&d=4&e=5
13+
--FILE--
14+
<?php
15+
var_dump($_POST);
16+
?>
17+
--EXPECT--
18+
Warning: Unknown: Input variables exceeded 4. To increase the limit change max_input_vars in php.ini. in Unknown on line 0
19+
array(0) {
20+
}

ext/mbstring/tests/bug63447_003.phpt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
--TEST--
2+
Bug #63447 (max_input_vars doesn't filter variables when mbstring.encoding_translation = On)
3+
--SKIPIF--
4+
<?php
5+
extension_loaded('mbstring') or die('skip');
6+
?>
7+
--INI--
8+
max_input_nesting_level=5
9+
max_input_vars=100
10+
mbstring.encoding_translation=1
11+
--POST--
12+
a=1&b[][][]=2&c[][][][][][]=7
13+
--FILE--
14+
<?php
15+
print_r($_POST);
16+
?>
17+
--EXPECT--
18+
Array
19+
(
20+
[a] => 1
21+
[b] => Array
22+
(
23+
[0] => Array
24+
(
25+
[0] => Array
26+
(
27+
[0] => 2
28+
)
29+
30+
)
31+
32+
)
33+
34+
)

0 commit comments

Comments
 (0)