ID: 24048
User updated by: mrgibson at golum dot net
Reported By: mrgibson at golum dot net
Status: Open
Bug Type: Reproducible crash
Operating System: windows 2000
PHP Version: 4.3.2
New Comment:
A little error:
replace $bof by $temp
and if ($file[0]=="#") continue;
is unnessesary
Previous Comments:
------------------------------------------------------------------------
[2003-06-05 13:51:36] mrgibson at golum dot net
Im running the code as a CLI application, i don't know if the bug
persist with the PHP module or CGI.
This is a little script that show the problem:
<?php
function recurse_search($dir,$pattern)
{
stdout_write("Recurse_search $dir,$pattern");
$temp = "";
$len = strlen($pattern);
$d = @opendir($dir);
if (!$d) die("Directory $dir not mounted or unavailable");
clearstatcache();
while($file = readdir($d))
{
if ($temp != "") break;
if ($file[0]==".") continue;
if ($file[0]=="#") continue;
stdout_write($file);
if (is_dir($dir.$file."/"))
{
stdout_write("DIR : $file");
$bof =
recurse_search($dir.$file."/",$pattern);
}
else
if (substr($file,0,$len)==$pattern)
{
close($d);
die($dir.$file);
return $dir.$file;
}
}
closedir($d);
return $temp;
}
}
function stdout_write($content)
{
$fp = fopen("php://stdout","w");
fwrite($content."\r\n");
fclose($fp);
}
print recurse_search("c:\\","system.ini");
?>
----------------------------------------------------
When i get back from a prior directory recursion, the
$file = readdir($d) stop working and the function exit.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=24048&edit=1