com php-src: Fixed bug #70947 (INI parser segfault with INI_SCANNER_TYPED): NEWS Zend/zend_ini_parser .y ext/standard/tests/general_functions/bug7094
7.phpt
| From: | Xinchen Hui | Date: | Fri, 20 Nov 2015 14:37:38 +0000 |
| Subject: | com php-src: Fixed bug #70947 (INI parser segfault with INI_SCANNER_TYPED): NEWS Zend/zend_ini_parser .y ext/standard/tests/general_functions/bug7094 7.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-89940@lists.php.net to get a copy of this message | ||
Commit: 519f9bc67520f2dfd43e4d829143721d1334ff59
Author: Xinchen Hui <laruence@gmail.com> Fri, 20 Nov 2015 06:37:38 -0800
Parents: 2a9fc35e5176633dc33496cae2efade99094a09d
Branches: PHP-7.0 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=519f9bc67520f2dfd43e4d829143721d1334ff59
Log:
Fixed bug #70947 (INI parser segfault with INI_SCANNER_TYPED)
Bugs:
https://bugs.php.net/70947
Changed paths:
M NEWS
M Zend/zend_ini_parser.y
A ext/standard/tests/general_functions/bug70947.phpt
Diff:
diff --git a/NEWS b/NEWS
index 69be876..4336257 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,7 @@ PHP NEWS
?? ??? 2015, PHP 7.0.1
- Core:
+ . Fixed bug #70947 (INI parser segfault with INI_SCANNER_TYPED). (Laruence)
. Fixed bug #70944 (try{ } finally{} can create infinite chains of
exceptions). (Laruence)
. Fixed bug #70914 (zend_throw_or_error() format string vulnerability).
diff --git a/Zend/zend_ini_parser.y b/Zend/zend_ini_parser.y
index e3042b8..d6f3315 100644
--- a/Zend/zend_ini_parser.y
+++ b/Zend/zend_ini_parser.y
@@ -109,8 +109,13 @@ static void zend_ini_add_string(zval *result, zval *op1, zval *op2)
ZVAL_PSTRINGL(op1, str->val, str->len);
zend_string_release(str);
}
-
op1_len = (int)Z_STRLEN_P(op1);
+
+ if (Z_TYPE_P(op2) != IS_STRING) {
+ zend_string *str = zval_get_string(op2);
+ ZVAL_PSTRINGL(op2, str->val, str->len);
+ zend_string_release(str);
+ }
length = op1_len + (int)Z_STRLEN_P(op2);
ZVAL_NEW_STR(result, zend_string_extend(Z_STR_P(op1), length, 1));
diff --git a/ext/standard/tests/general_functions/bug70947.phpt
b/ext/standard/tests/general_functions/bug70947.phpt
new file mode 100644
index 0000000..d07e5a3
--- /dev/null
+++ b/ext/standard/tests/general_functions/bug70947.phpt
@@ -0,0 +1,12 @@
+--TEST--
+Bug #70947 (INI parser segfault with INI_SCANNER_TYPED)
+--FILE--
+<?php
+$o = parse_ini_string('foo = bar 123', FALSE, INI_SCANNER_TYPED);
+var_dump($o);
+?>
+--EXPECT--
+array(1) {
+ ["foo"]=>
+ string(7) "bar 123"
+}