]> granicus.if.org Git - php/commitdiff
Fix bug #74603 - use correct buffer size
authorStanislav Malyshev <stas@php.net>
Tue, 20 Jun 2017 07:09:01 +0000 (00:09 -0700)
committerStanislav Malyshev <stas@php.net>
Wed, 5 Jul 2017 02:35:56 +0000 (19:35 -0700)
Zend/tests/bug74603.ini [new file with mode: 0644]
Zend/tests/bug74603.phpt [new file with mode: 0644]
Zend/zend_ini_parser.y

diff --git a/Zend/tests/bug74603.ini b/Zend/tests/bug74603.ini
new file mode 100644 (file)
index 0000000..8d74a57
--- /dev/null
@@ -0,0 +1 @@
+0=0&~2000000000
diff --git a/Zend/tests/bug74603.phpt b/Zend/tests/bug74603.phpt
new file mode 100644 (file)
index 0000000..b3194ec
--- /dev/null
@@ -0,0 +1,15 @@
+--TEST--
+Bug #74603 (PHP INI Parsing Stack Buffer Overflow Vulnerability)
+--SKIPIF--
+<?php
+if (PHP_INT_MAX !== 2147483647)
+        die('skip for 32-bit only');
+--FILE--
+<?php
+var_dump(parse_ini_file(__DIR__ . "/bug74603.ini", true, INI_SCANNER_NORMAL));
+?>
+--EXPECT--
+array(1) {
+  [0]=>
+  string(1) "0"
+}
index e83f02f98338e408e2fcea5a48344958e91b35ed..f25258108150a7d2e57e0e3c2229a473119e80d7 100644 (file)
@@ -55,7 +55,7 @@ static void zend_ini_do_op(char type, zval *result, zval *op1, zval *op2)
        int i_result;
        int i_op1, i_op2;
        int str_len;
-       char str_result[MAX_LENGTH_OF_LONG];
+       char str_result[MAX_LENGTH_OF_LONG+1];
 
        i_op1 = atoi(Z_STRVAL_P(op1));
        zend_string_free(Z_STR_P(op1));