#36320 [NEW]: Custom dir_readdir() causes readdir() to crash when returns false

From: Date: Tue, 07 Feb 2006 15:16:32 +0000
Subject: #36320 [NEW]: Custom dir_readdir() causes readdir() to crash when returns false
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-93017@lists.php.net to get a copy of this message
From: Jared dot Williams1 at ntlworld dot com Operating system: Win2000 PHP version: 5.1.2 PHP Bug Type: Streams related Bug description: Custom dir_readdir() causes readdir() to crash when returns false Description: ------------ dir_readdir seems to cause a crash when used with readdir(). Code below is based on the \ext\standard\tests\file\userdirstream.phpt test, but instead of using scandir() which appears to work fine, the manual looping causes an application exception. Reproduce code: --------------- class test { public $idx = 0; function dir_opendir($path, $options) { print "Opening\n"; $this->idx = 0; return true; } function dir_readdir() { $sample = array('first','second','third','fourth'); if ($this->idx >= count($sample)) return false; else return $sample[$this->idx++]; } function dir_rewinddir() { $this->idx = 0; return true; } function dir_closedir() { print "Closing up!\n"; return true; } } stream_wrapper_register('test', 'test'); $dh = opendir('test://example.com/path/to/test'); if ($dh) { while (($f = readdir($dh)) !== FALSE) echo $f, "\n"; } Expected result: ---------------- Opening first second third fourth without an application exception Actual result: -------------- Opening first second third fourth with an application exception -- Edit bug report at http://bugs.php.net/?id=36320&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=36320&r=trysnapshot44 Try a CVS snapshot (PHP 5.1): http://bugs.php.net/fix.php?id=36320&r=trysnapshot51 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=36320&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=36320&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=36320&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=36320&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=36320&r=needscript Try newer version: http://bugs.php.net/fix.php?id=36320&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=36320&r=support Expected behavior: http://bugs.php.net/fix.php?id=36320&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=36320&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=36320&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=36320&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=36320&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=36320&r=dst IIS Stability: http://bugs.php.net/fix.php?id=36320&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=36320&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=36320&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=36320&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=36320&r=mysqlcfg

« previous php.bugs (#93017) next »