Skip to content

Fix OSS-Fuzz #428983568 and #428760800 #19012

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: PHP-8.3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
  • Loading branch information
nielsdos committed Jul 2, 2025
commit def69b8aed0b1e8bc3e6b78f02ace0bd4fcaebed
14 changes: 14 additions & 0 deletions Zend/tests/zend_ini/oss_fuzz_428983568.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--TEST--
OSS-Fuzz #428983568
--FILE--
<?php
$ini = <<<INI
[\${zz:-x

INI;
var_dump(parse_ini_string($ini));
?>
--EXPECTF--
Warning: syntax error, unexpected end of file, expecting '}' in Unknown on line 1
in %s on line %d
bool(false)
2 changes: 1 addition & 1 deletion Zend/zend_ini_parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ static void normalize_value(zval *zv)
%left '|' '&' '^'
%precedence '~' '!'

%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
%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

%%

Expand Down
Loading