php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80860 Every ((65535*n)-1)th element in glob() and DirectoryIterator() appears twice
Submitted: 2021-03-13 12:02 UTC Modified: 2021-03-13 12:10 UTC
From: andrey dot budko at gmail dot com Assigned: cmb (profile)
Status: Duplicate Package: *Directory/Filesystem functions
PHP Version: 7.4.16 OS: win7, win10
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: andrey dot budko at gmail dot com
New email:
PHP Version: OS:

 

 [2021-03-13 12:02 UTC] andrey dot budko at gmail dot com
Description:
------------
Every ((65535*n)-1)th element in glob() and DirectoryIterator() appears twice. 

Values of glob() array are not unique.

Test script:
---------------
<?php

function foo($tmp_dir, $count){
  for($i = 1; $i <= $count; $i++){
    @mkdir($tmp_dir.'/'.$i, 0777, true);
  }

  $count_glob = count(glob($tmp_dir.'/*'), GLOB_ONLYDIR);

  $count_dir_iterator = 0;
  $dir = new \DirectoryIterator($tmp_dir);
  foreach($dir as $fileInfo){
    if($fileInfo->isDir() && !$fileInfo->isDot()){
      $count_dir_iterator++;
    }
  }
  return [$count_glob, $count_dir_iterator];
}

echo foo('d:/test', 65533)."\n"; // 65533
echo foo('d:/test', 65534)."\n"; // 65535
echo foo('d:/test', 131068)."\n"; // 131069
echo foo('d:/test', 131069)."\n"; // 131071




Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-03-13 12:10 UTC] cmb@php.net
-Status: Open +Status: Duplicate -Assigned To: +Assigned To: cmb
 [2021-03-13 12:10 UTC] cmb@php.net
This is a duplicate of bug #36365, which cannot be fixed for PHP
7.4 for BC reasons.
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Wed Jun 23 00:01:23 2021 UTC