mirror of
https://github.com/bdnugget/php-src.git
synced 2026-11-07 09:17:29 +00:00
Fix #36365: scandir duplicates file name at every 65535th file
Since DIR_W32.offset is declared as `uint16_t`, we have an overflow for directories with many entries. This patch changes the field to `uint32_t`.
This commit is contained in:
1 parent
41a04f96b4
commit
767a77ac19
3 files changed
+30
-1
No files matched your search
@@ -20,6 +20,8 @@ PHP NEWS
|
||||
(cmb)
|
||||
. Fixed bug #79368 ("Unexpected end of file" is not an acceptable error
|
||||
message). (Alex Dowad)
|
||||
. Fixed bug #36365 (scandir duplicates file name at every 65535th file).
|
||||
(cmb)
|
||||
|
||||
- BZ2:
|
||||
. Fixed bug #71263 (fread() does not report bzip2.decompress errors). (cmb)
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
--TEST--
|
||||
Bug #36365 (scandir duplicates file name at every 65535th file)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (getenv("SKIP_SLOW_TESTS")) die('skip slow test');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$testdir = __DIR__ . '/bug36365';
|
||||
|
||||
mkdir($testdir);
|
||||
for ($i = 0; $i < 70000; $i++) {
|
||||
touch(sprintf("$testdir/%05d.txt", $i));
|
||||
}
|
||||
|
||||
var_dump(count(scandir($testdir)));
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
$testdir = __DIR__ . '/bug36365';
|
||||
for ($i = 0; $i < 70000; $i++) {
|
||||
unlink(sprintf("$testdir/%05d.txt", $i));
|
||||
}
|
||||
rmdir($testdir);
|
||||
?>
|
||||
--EXPECT--
|
||||
int(70002)
|
||||
+1
-1
@@ -26,7 +26,7 @@ struct dirent {
|
||||
/* typedef DIR - not the same as Unix */
|
||||
struct DIR_W32 {
|
||||
HANDLE handle; /* _findfirst/_findnext handle */
|
||||
uint16_t offset; /* offset into directory */
|
||||
uint32_t offset; /* offset into directory */
|
||||
uint8_t finished; /* 1 if there are not more files */
|
||||
WIN32_FIND_DATAW fileinfo; /* from _findfirst/_findnext */
|
||||
wchar_t *dirw; /* the dir we are reading */
|
||||
|
||||
Reference in new issue
Block a user