php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #21410 file_exists(), filetype() do not return FALSE for bad filenames: "" or NULL
Submitted: 2003-01-04 13:29 UTC Modified: 2003-02-27 10:42 UTC
Votes:2
Avg. Score:4.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:2 (100.0%)
From: ari at alienhosting dot com Assigned:
Status: Closed Package: Filesystem function related
PHP Version: 4.3.2-dev OS: win32 only
Private report: No CVE-ID: None
 [2003-01-04 13:29 UTC] ari at alienhosting dot com
In the filetype() doc, it says the function returns FALSE on error, but says nothing about a warning being output if it fails. In 4.3.0, A warning is printed:

Warning: filetype() [function.filetype]: Lstat failed for (null) (errno=2 - No such file or directory) in /home/alienhosting/public_html/webmail/plugins/administrator/options.php on line 431

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-01-04 14:37 UTC] nicos@php.net
Changing this bug to a documentation problem.

The warning are now expected for 2 cases: when stat or lstat have failed and when the file type is unknown.

I'm working on fixing the documentation.
 [2003-01-04 14:43 UTC] nicos@php.net
The documentation now warns about the warnings :-)

Thank you for your report.
 [2003-01-04 15:12 UTC] philip@php.net
I experience this E_WARNING in linux but in Windows I always get the following with 4.3.0/win2000:

var_dump( filetype(null) ); // string(3) "dir"

Which seems odd.  Basically instead of the E_WARNING error it shows the bogus file as a dir.  This happens with CGI, CLI, and Apache2.

Marking this as a filesystem bug.
 [2003-01-04 15:30 UTC] philip@php.net
To be clearer:  This happens with any bogus information, whether it be a string, NULL, or otherwise.

Of course passing no arguments still results in the standard wrong parameter count error.
 [2003-02-19 23:59 UTC] sniper@php.net
Tested with latest CVS snapshot..

 [2003-02-20 00:09 UTC] sniper@php.net
Cause of this is that in win32, php_stat() never
tests whether the file exists or not.

 [2003-02-25 02:56 UTC] sniper@php.net
Same basic problem with file_exists() too..

 [2003-02-25 02:59 UTC] sniper@php.net
Just to clarify:

The base function that is used should check that the 
passed parameter is a) valid b) if valid, the file exists

 [2003-02-27 10:42 UTC] iliaa@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at http://snaps.php.net/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 16:01:28 2024 UTC