From: mrgibson at golum dot net
Operating system: windows 2000
PHP version: 4.3.2
PHP Bug Type: Reproducible crash
Bug description: opendir() drop the previous directory pointer
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 bug report at http://bugs.php.net/?id=24048&edit=1
--
Try a CVS snapshot: http://bugs.php.net/fix.php?id=24048&r=trysnapshot
Fixed in CVS: http://bugs.php.net/fix.php?id=24048&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=24048&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=24048&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=24048&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=24048&r=support
Expected behavior: http://bugs.php.net/fix.php?id=24048&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=24048&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=24048&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=24048&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=24048&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=24048&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=24048&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=24048&r=gnused