1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

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

Setting check_null previously was due to misunderstanding its purpose
This commit is contained in:
David CARLIER
2025-02-16 11:14:19 +00:00
committed by GitHub
parent a1da7cac85
commit 3b82367871
2 changed files with 9 additions and 2 deletions

View File

@@ -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();

View File

@@ -49,6 +49,7 @@ try {
echo $e->getMessage(), PHP_EOL;
}
zend_test_compile_string(null, null, null);
$source_string = <<<EOF
<?php
@@ -58,7 +59,7 @@ 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"
@@ -66,4 +67,10 @@ 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