php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #61049 Fopen detects non existing file
Submitted: 2012-02-10 19:27 UTC Modified: 2012-02-10 20:32 UTC
From: kasper at webmasteren dot eu Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 5.3.8, 5.3.9 OS: windows
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: kasper at webmasteren dot eu
New email:
PHP Version: OS:

 

 [2012-02-10 19:27 UTC] kasper at webmasteren dot eu
Description:
------------
Tested under PHP version 5.3.8 and 5.3.9, both running xdebug and a lot of other 
standard plugins.
The problem is for some reason that PHP simply cannot create / open a file named 
"../api/cache/con.js" which seems rather strange,since there is no keywords 
(from what i could find) there would even suggest that it could be the reason. 
i have used the software packet called "wamp". 

Configuration line:
cscript /nologo configure.js "--enable-snapshot-build" "--with-pdo-oci=C:\php-
sdk\php53dev\vc9\x64\deps\instantclient_10_2\sdk,shared" "--with-oci8=C:\php-
sdk\php53dev\vc9\x64\deps\instantclient_10_2\sdk,shared" "--with-oci8-
11g=C:\php-sdk\php53dev\vc9\x64\deps\instantclient_11_2\sdk,shared" "--disable-
debug-pack" "--disable-static-analyze"

the version API:
API20090626,TS,VC9


The test script:
inside af subfolder, on a webserver, put this, and make sure that ../api/cache 
folder exists.

futher more, when using the SplFileInfo the method "getType" tells me that it is 
a file. the method "getAbsolutePath" returns "c:\wamp\www\api\cache\CON" and the 
"getFileName" returns "CON.js". 

Test script:
---------------
fopen("../api/cache/con.js","w");


Expected result:
----------------
Warning: fopen(../api/cache/con.js) [function.fopen]: failed to open stream: Bad 
file descriptor in C:\wamp\www\teater\indexa.php on line 3



Actual result:
--------------
Warning: fopen(../api/cache/con.js) [function.fopen]: failed to open stream: Bad 
file descriptor in C:\wamp\www\teater\indexa.php on line 3


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-02-10 19:28 UTC] kasper at webmasteren dot eu
realized the version was wrong (the date)
 [2012-02-10 19:28 UTC] kasper at webmasteren dot eu
-PHP Version: 5.3SVN-2012-02-10 (snap) +PHP Version: 5.3.8, 5.3.9
 [2012-02-10 20:32 UTC] cataphract@php.net
-Status: Open +Status: Not a bug
 [2012-02-10 20:32 UTC] cataphract@php.net
This is a Win32 quirk. The interface PHP uses has problems with files named CON, 
among others:

http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx

«Do not use the following reserved device names for the name of a file:
CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, LPT1, 
LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9. Also avoid these names 
followed immediately by an extension; for example, NUL.txt is not recommended. 
For more information, see Namespaces.»
 [2012-02-10 20:33 UTC] anon at anon dot anon
Sadly this is a Windows limitation. On Windows you cannot create a file named "con", "aux", "prn", or "nul", regardless of case. They are reserved device names that exist for historical reasons ("con" for example is the stdin/stdout). For some mad reason, this limitation still applies regardless of the file extension!! Try simply in Notepad to save a file called con.txt and it'll fail just the same.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun May 04 09:01:28 2025 UTC