Skip to content

Commit e3ffe53

Browse files
committed
Fix OSS-Fuzz #428983568 and #428760800
Both these issues have the same root cause, their reproducer is extremely similar so I don't duplicate the test. If the parser invokes the lexer, and the lexer fails, it could've allocated a string which must be freed when the parser backs up. The `%destructor` list is responsible for this but did not have an entry for `fallback` yet. Solve the issue by adding such an entry.
1 parent 69328ba commit e3ffe53

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
OSS-Fuzz #428983568
3+
--FILE--
4+
<?php
5+
$ini = <<<INI
6+
[\${zz:-x
7+
8+
INI;
9+
var_dump(parse_ini_string($ini));
10+
?>
11+
--EXPECTF--
12+
Warning: syntax error, unexpected end of file, expecting '}' in Unknown on line 1
13+
in %s on line %d
14+
bool(false)

‎Zend/zend_ini_parser.y

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ static void normalize_value(zval *zv)
353353
%left '|' '&' '^'
354354
%precedence '~' '!'
355355
356-
%destructor { zval_ini_dtor(&$$); } TC_RAW TC_CONSTANT TC_NUMBER TC_STRING TC_WHITESPACE TC_LABEL TC_OFFSET TC_VARNAME BOOL_TRUE BOOL_FALSE NULL_NULL cfg_var_ref constant_literal constant_string encapsed_list expr option_offset section_string_or_value string_or_value var_string_list var_string_list_section
356+
%destructor { zval_ini_dtor(&$$); } TC_RAW TC_CONSTANT TC_NUMBER TC_STRING TC_WHITESPACE TC_LABEL TC_OFFSET TC_VARNAME BOOL_TRUE BOOL_FALSE NULL_NULL cfg_var_ref constant_literal constant_string encapsed_list expr option_offset fallback section_string_or_value string_or_value var_string_list var_string_list_section
357357
358358
%%
359359

0 commit comments

Comments
 (0)