Skip to content

Commit

Permalink
Fix PHP_MAXPATHLEN check
Browse files Browse the repository at this point in the history
The previous test was wrong. In fact, `PHP_MAXPATHLEN` is not the maximum length of a file, but `PHP_MAXPATHLEN - 1`. This is checked internally in the PHP source code and if the file is PHP_MAXPATHLEN characters long or longer, the error is thrown in Open-Base-Dir [1].

The problem was incompletely fixed here: laravel#50962

[1] https://github.com/php/php-src/blob/7c860628cd2bf11ee867bfb41b3fd0314c5177c5/main/fopen_wrappers.c#L301
  • Loading branch information
joshuaruesweg committed Jun 20, 2024
1 parent 12e51dd commit f469276
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Illuminate/View/FileViewFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ protected function findInPaths($name, $paths)
foreach ($this->getPossibleViewFiles($name) as $file) {
$viewPath = $path.'/'.$file;

if (strlen($viewPath) <= PHP_MAXPATHLEN && $this->files->exists($viewPath)) {
if (strlen($viewPath) < (PHP_MAXPATHLEN - 1) && $this->files->exists($viewPath)) {
return $viewPath;
}
}
Expand Down

0 comments on commit f469276

Please sign in to comment.