-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #65069: GlobIterator incorrect handling of open_basedir check
- Loading branch information
Showing
3 changed files
with
95 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
--TEST-- | ||
Bug #65069: GlobIterator fails to access files inside an open_basedir restricted dir | ||
--FILE-- | ||
<?php | ||
$file_path = dirname(__FILE__); | ||
// temp dirname used here | ||
$dirname = "$file_path/bug65069"; | ||
// temp dir created | ||
mkdir($dirname); | ||
|
||
ini_set('open_basedir', $dirname); | ||
|
||
// temp files created | ||
$fp = fopen("$dirname/wonder12345", "w"); | ||
fclose($fp); | ||
$fp = fopen("$dirname/wonder.txt", "w"); | ||
fclose($fp); | ||
$fp = fopen("$dirname/file.text", "w"); | ||
fclose($fp); | ||
|
||
$spl_glob_it = new \GlobIterator("$dirname/*.txt"); | ||
foreach ($spl_glob_it as $file_info) { | ||
echo $file_info->getFilename() . "\n"; | ||
} | ||
|
||
$spl_glob_it = new \GlobIterator(dirname(dirname($dirname)) . "/*/*/*"); | ||
foreach ($spl_glob_it as $file_info) { | ||
echo $file_info->getFilename() . "\n"; | ||
} | ||
|
||
$spl_glob_empty = new \GlobIterator("$dirname/*.php"); | ||
var_dump($spl_glob_empty->count()); | ||
|
||
// top directory | ||
var_dump(iterator_to_array(new \GlobIterator(dirname(dirname($dirname))))); | ||
|
||
// not existing file | ||
var_dump(iterator_to_array(new \GlobIterator("$file_path/bug65069-this-will-never-exists"))); | ||
|
||
|
||
?> | ||
--CLEAN-- | ||
<?php | ||
$file_path = dirname(__FILE__); | ||
$dirname = "$file_path/bug65069"; | ||
unlink("$dirname/wonder12345"); | ||
unlink("$dirname/wonder.txt"); | ||
unlink("$dirname/file.text"); | ||
rmdir($dirname); | ||
?> | ||
--EXPECT-- | ||
wonder.txt | ||
file.text | ||
wonder.txt | ||
wonder12345 | ||
int(0) | ||
array(0) { | ||
} | ||
array(0) { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters