php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26210 CON, NUL, PRN... special files : is_file return true
Submitted: 2003-11-12 00:18 UTC Modified: 2003-11-12 04:55 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: iubito at asp-php dot net Assigned:
Status: Not a bug Package: *Directory/Filesystem functions
PHP Version: 4.3.3 OS: Windows (all)
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: iubito at asp-php dot net
New email:
PHP Version: OS:

 

 [2003-11-12 00:18 UTC] iubito at asp-php dot net
Description:
------------
Hello

As we often forget that Windows is based on DOS... we forget that in DOS it exists special file (CON, NUL, PRN, LPT1, LPT2, AUX, COM1, COM2, COM3, COM4). Under DOS, echo foobar > nul
nul is considered as a file.

Now in Windows Explorer, if you try to create a file called aux.<the_extension_you_want> or nul.bmp or prn.zip or lpt2.php... Windows return an error, something like "Impossible to create nul.bmp, a file with this name already exists..."
That shows us that windows consider aux.* nul.* con.* as files.

Now here I want to go...
All functions like is_directory, is_file, file_exists... should return false.
Since today, it ask windows "does the file nul.bmp exist ?" and Windows answer "yes!".
But this file is not openable, writeable, readable.

Reproduce code:
---------------
<?
$bugfile = 'c:/nul.gif'; // or aux.* or con.*....
if (is_file($bugfile))
  echo $bugfile.' exists! <img src="'.$bugfile.'" />';
else
  echo $bugfile.' doesn\'t exist!';

// Now is a more problematic case I've seen in my app
$inc = 'aux.php'; // the name is generated automatically...
if (is_file('mydirectory/'.$inc)) {
  include('mydirectory/'.$inc);
}

?>

Expected result:
----------------
c:/nul.gif doesn't exist!

Actual result:
--------------
c:/nul.gif exists <img src="c:/nul.gif" /> <-- that's a red cross!

Warning: main(PHPmyBrowserCustom/addon-file/AUX.php): failed to open stream: No such file or directory in F:\www\pays\flags\PHPmyBrowser\main.php on line 587

Fatal error: main(): Failed opening required 'PHPmyBrowserCustom/addon-file/AUX.php' (include_path='.;c:\php4\pear') in F:\www\pays\flags\PHPmyBrowser\main.php on line 587


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-11-12 04:12 UTC] edink@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

.
 [2003-11-12 04:55 UTC] iubito at asp-php dot net
Sorry but the problem is serious, and I've found in the doc (just now, didn't found it before :p) filetype...

...BUT that doesn't solve the problem. If only I could test if my files are "file" type!

with filetype($a_file_name)
c:/ -> dir
brass.mus -> file
file_that_not_exist.foobar -> 
aux.* -> file
nul.* -> file
com1.* -> file

Is filetype() function correct ???
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 09:01:28 2024 UTC