Skip to content

Fix GH-17831: zend_test_compile_string crash on nul bytes check. #17832

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

Merged
merged 2 commits into from
Feb 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ext/zend_test/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ static ZEND_FUNCTION(zend_test_compile_string)

ZEND_PARSE_PARAMETERS_START(3, 3)
Z_PARAM_STR(source_string)
Z_PARAM_PATH_STR_EX(filename, 1, 0)
Z_PARAM_PATH_STR(filename)
Z_PARAM_LONG(position)
ZEND_PARSE_PARAMETERS_END();

Expand Down
9 changes: 8 additions & 1 deletion ext/zend_test/tests/zend_test_compile_string.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ try {
echo $e->getMessage(), PHP_EOL;
}

zend_test_compile_string(null, null, null);

$source_string = <<<EOF
<?php
Expand All @@ -58,12 +59,18 @@ EOF;
zend_test_compile_string($source_string, 'Source string', ZEND_COMPILE_POSITION_AFTER_OPEN_TAG);

?>
--EXPECT--
--EXPECTF--
string(3) "php"
#!/path/to/php
string(3) "php"
string(3) "php"
string(3) "php"
zend_test_compile_string(): Argument #2 ($filename) must not contain any null bytes

Deprecated: zend_test_compile_string(): Passing null to parameter #1 ($source_string) of type string is deprecated in %s on line %d

Deprecated: zend_test_compile_string(): Passing null to parameter #2 ($filename) of type string is deprecated in %s on line %d

Deprecated: zend_test_compile_string(): Passing null to parameter #3 ($position) of type int is deprecated in %s on line %d

Parse error: syntax error, unexpected token "<", expecting end of file in Source string on line 1
Loading