Skip to content

Commit 4aac98f

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. Closes GH-19012.
1 parent 304d223 commit 4aac98f

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ PHP NEWS
99
. Fixed bug GH-18833 (Use after free with weakmaps dependent on destruction
1010
order). (Daniil Gentili)
1111
. Fix OSS-Fuzz #427814456. (nielsdos)
12+
. Fix OSS-Fuzz #428983568 and #428760800. (nielsdos)
1213

1314
- Curl:
1415
. Fix memory leaks when returning refcounted value from curl callback.
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 fallback option_offset section_string_or_value string_or_value var_string_list var_string_list_section
357357
358358
%%
359359

0 commit comments

Comments
 (0)