Skip to content

Commit 421a734

Browse files
committed
Merge branch 'PHP-7.4'
* PHP-7.4: Fixed bug #79244 (php crashes during parsing INI file). (Laruence)
2 parents 86780ff + 6295ff7 commit 421a734

File tree

2 files changed

+48
-7
lines changed

2 files changed

+48
-7
lines changed

Zend/tests/bug77589.phpt

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
--TEST--
2+
BUG #77589 (Core dump using parse_ini_string with numeric sections)
3+
--FILE--
4+
<?php
5+
var_dump(
6+
parse_ini_string(<<<INI
7+
[0]
8+
a = 1
9+
b = on
10+
c = true
11+
12+
["true"]
13+
a = 100
14+
b = null
15+
c = yes
16+
INI
17+
, TRUE, INI_SCANNER_TYPED));
18+
19+
?>
20+
--EXPECT--
21+
array(2) {
22+
[0]=>
23+
array(3) {
24+
["a"]=>
25+
int(1)
26+
["b"]=>
27+
bool(true)
28+
["c"]=>
29+
bool(true)
30+
}
31+
["true"]=>
32+
array(3) {
33+
["a"]=>
34+
int(100)
35+
["b"]=>
36+
NULL
37+
["c"]=>
38+
bool(true)
39+
}
40+
}

Zend/zend_ini_scanner.l

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -141,13 +141,14 @@ ZEND_API zend_ini_scanner_globals ini_scanner_globals;
141141
ZVAL_NEW_STR(retval, zend_string_init(str, len, ZEND_SYSTEM_INI))
142142

143143

144-
#define RETURN_TOKEN(type, str, len) { \
145-
if (SCNG(scanner_mode) == ZEND_INI_SCANNER_TYPED) { \
146-
zend_ini_copy_typed_value(ini_lval, type, str, len); \
147-
} else { \
148-
zend_ini_copy_value(ini_lval, str, len); \
149-
} \
150-
return type; \
144+
#define RETURN_TOKEN(type, str, len) { \
145+
if (SCNG(scanner_mode) == ZEND_INI_SCANNER_TYPED && \
146+
(YYSTATE == STATE(ST_VALUE) || YYSTATE == STATE(ST_RAW))) {\
147+
zend_ini_copy_typed_value(ini_lval, type, str, len); \
148+
} else { \
149+
zend_ini_copy_value(ini_lval, str, len); \
150+
} \
151+
return type; \
151152
}
152153

153154
static inline int convert_to_number(zval *retval, const char *str, const int str_len)

0 commit comments

Comments
 (0)