php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #62047 IIS 6.0 & PHP 5.4.3 / IIS 6.0 & PHP PHP 5.3.8 / Apache 2.2.21 & PHP 5.3.8
Submitted: 2012-05-16 14:46 UTC Modified: 2012-05-17 02:03 UTC
Votes:2
Avg. Score:4.0 ± 1.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: turboe at gmx dot de Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: Irrelevant OS: Win7/WinXP
Private report: No CVE-ID:
 [2012-05-16 14:46 UTC] turboe at gmx dot de
Description:
------------
Problem with openDir/readDir:
A folder with the name "0" breaks openDir/readDir.

Sometimes you will have different orders,
but the script breaks on the folder with the name "0".

Tested on PHP 5.4 and 5.3 on different Webservers. (IIS + Apache) and different OS (Win7 + WinXP)

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

$verzeichnis2 = openDir("//fileserver/Daten/");
while ($file2 = readDir($verzeichnis2)) 
{
	echo $file2;
	echo "<br>";
}

?>

Expected result:
----------------
folders:
.
..
0
1
2







Actual result:
--------------
Output from the example-script:
.
..


If you rename the Dir "0" to "X0" the output looks like:
.
..
X0
1
2

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-05-17 02:03 UTC] laruence@php.net
-Status: Open +Status: Not a bug
 [2012-05-17 02:03 UTC] laruence@php.net
This function(readdir) may return Boolean FALSE, but may also return a non-
Boolean value which evaluates to FALSE. Please read the section on Booleans for 
more information. Use the === operator, see: 
http://www.php.net/manual/en/function.readdir.php

which means you should write your code  like :

while (($file2 = readDir($verzeichnis2)) !== FALSE) 
{
	echo $file2;
	echo "<br>";
}
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Thu Apr 17 12:01:59 2014 UTC