Bug #52966 [Opn]: No error with endless dir()
| From: | cataphract@php.net | Date: | Fri, 01 Oct 2010 20:11:28 +0000 |
| Subject: | Bug #52966 [Opn]: No error with endless dir() | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-154812@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=52966&edit=1
ID: 52966
Updated by: cataphract@php.net
Reported by: grzegorz at securelink dot pl
Summary: No error with endless dir()
Status: Open
Type: Bug
Package: Directory function related
Operating System: Linux
PHP Version: 5.3.3
Block user comment: N
New Comment:
PHP cannot guess what you want to do and warn you if the code you write
doesn't do it. It's your responsibility to write correct programs.
Previous Comments:
------------------------------------------------------------------------
[2010-10-01 20:27:03] grzegorz at securelink dot pl
Description:
------------
Hi!
I writted buggy code and php engine crashed.
Test script:
---------------
function list_dir($dir) {
$d = dir($dir);
while (false !== ($entry = $d->read())) {
if(is_dir($entry)) {
if($entry != "." && $entry != "..") { continue; }
list_dir("$dir/$entry");
} else {
echo "$dir/$entry\n";
}
}
}
list_dir("/");
Expected result:
----------------
Hmm ... I want some error or warning.
Actual result:
--------------
PHP Warning:
dir(/var/www/priv/./././././././././././././././././././././././././././././././
././././././././././././././././././././././././././././././././././././././././
././././././././././././././././././././././././././././././././././././././././
././././././././././././././././././././././././././././././././././././././././
././././././././././././././././././././././././././././././././././././././././
././././././././././././././././././././././././././././././././././././././././
././././././././././././././././././././././././././././././././././././././././
././././././././././././././././././././././././././././././././././././././././
././././././././././././././././././././././././././././././././././././././././
././././././././././././././././././././././././././././././././././././././././
././././././././././././././././././././././././././././././././././././././././
././././././././././././././././././././././././././././././././././././././././
././././././././././././././././././././././././././././././././ in
/var/www/priv/dir_tree.php on line 3
Warning:
dir(/var/www/priv/./././././././././././././././././././././././././././././././
././././././././././././././././././././././././././././././././././././././././
././././././././././././././././././././././././././././././././././././././././
././././././././././././././././././././././././././././././././././././././././
././././././././././././././././././././././././././././././././././././././././
././././././././././././././././././././././././././././././././././././././././
././././././././././././././././././././././././././././././././././././././././
././././././././././././././././././././././././././././././././././././././././
././././././././././././././././././././././././././././././././././././././././
././././././././././././././././././././././././././././././././././././././././
././././././././././././././././././././././././././././././././././././././././
././././././././././././././././././././././././././././././././././././././././
././././././././././././././././././././././././././././././././ in
/var/www/priv/dir_tree.php on line 3
PHP Fatal error: Call to a member function read() on a non-object in
/var/www/priv/dir_tree.php on line 4
Fatal error: Call to a member function read() on a non-object in
/var/www/priv/dir_tree.php on line 4
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=52966&edit=1