mirror of
https://github.com/php/php-src.git
synced 2026-03-27 09:42:22 +01:00
Currently we treat paths with null bytes as a TypeError, which is incorrect, and rather inconsistent, as we treat empty paths as ValueError. We do this because the error is generated by zpp and it's easier to always throw TypeError there. This changes the zpp implementation to throw a TypeError only if the type is actually wrong and throw ValueError for null bytes. The error message is also split accordingly, to be more precise. Closes GH-6094.
32 lines
741 B
PHP
32 lines
741 B
PHP
--TEST--
|
|
Bug #78863 (DirectoryIterator class silently truncates after a null byte)
|
|
--FILE--
|
|
<?php
|
|
$dir = __DIR__ . '/bug78863';
|
|
mkdir($dir);
|
|
touch("$dir/bad");
|
|
mkdir("$dir/sub");
|
|
touch("$dir/sub/good");
|
|
|
|
$it = new DirectoryIterator(__DIR__ . "/bug78863\0/sub");
|
|
foreach ($it as $fileinfo) {
|
|
if (!$fileinfo->isDot()) {
|
|
var_dump($fileinfo->getFilename());
|
|
}
|
|
}
|
|
?>
|
|
--EXPECTF--
|
|
Fatal error: Uncaught ValueError: DirectoryIterator::__construct(): Argument #1 ($path) must not contain any null bytes in %s:%d
|
|
Stack trace:
|
|
#0 %s(%d): DirectoryIterator->__construct('%s')
|
|
#1 {main}
|
|
thrown in %s on line %d
|
|
--CLEAN--
|
|
<?php
|
|
$dir = __DIR__ . '/bug78863';
|
|
unlink("$dir/sub/good");
|
|
rmdir("$dir/sub");
|
|
unlink("$dir/bad");
|
|
rmdir($dir);
|
|
?>
|