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

Merge branch 'PHP-8.3' into PHP-8.4

This commit is contained in:
David Carlier
2025-02-15 10:12:20 +00:00
2 changed files with 38 additions and 1 deletions

View File

@@ -0,0 +1,31 @@
--TEST--
GH-17797 (zend_test_compile_string crash on invalid script path)
--EXTENSIONS--
zend_test
--CREDITS--
YuanchengJiang
--FILE--
<?php
$source = '<?php
require("sumfile.php");
?>';
try {zend_test_compile_string($source,$source,$c);} catch (Exception $e) { echo($e); }
--EXPECTF--
Warning: Undefined variable $c 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
Warning: require(sumfile.php): Failed to open stream: No such file or directory in <?php
require("sumfile.php");
?> on line %d
Fatal error: Uncaught Error: Failed opening required 'sumfile.php' (include_path='.%s') in <?php
require("sumfile.php");
?>:%d
Stack trace:
#0 %s(%d): zend_test_compile_string('<?php\nrequire("...', '<?php\nrequire("...', NULL)
#1 {main}
thrown in <?php
require("sumfile.php");
?> on line %d

View File

@@ -603,7 +603,13 @@ PHPAPI zend_string *php_resolve_path(const char *filename, size_t filename_lengt
const char *exec_fname = ZSTR_VAL(exec_filename);
size_t exec_fname_length = ZSTR_LEN(exec_filename);
while ((--exec_fname_length < SIZE_MAX) && !IS_SLASH(exec_fname[exec_fname_length]));
while (exec_fname_length > 0) {
--exec_fname_length;
if (IS_SLASH(exec_fname[exec_fname_length])) {
break;
}
}
if (exec_fname_length > 0 &&
filename_length < (MAXPATHLEN - 2) &&
exec_fname_length + 1 + filename_length + 1 < MAXPATHLEN) {