php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52966 No error with endless dir()
Submitted: 2010-10-01 20:27 UTC Modified: 2010-10-01 22:11 UTC
Votes:1
Avg. Score:1.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: grzegorz at securelink dot pl Assigned:
Status: Not a bug Package: Directory function related
PHP Version: 5.3.3 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: grzegorz at securelink dot pl
New email:
PHP Version: OS:

 

 [2010-10-01 20:27 UTC] 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


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-10-01 22:11 UTC] cataphract@php.net
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.
 [2010-10-01 22:11 UTC] cataphract@php.net
-Status: Open +Status: Bogus
 [2010-10-01 22:11 UTC] cataphract@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 02:01:29 2024 UTC