php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31347 is_dir and is_file (incorrectly) return true for any string > 255 characters
Submitted: 2004-12-30 10:43 UTC Modified: 2005-12-20 15:28 UTC
Votes:6
Avg. Score:4.7 ± 0.5
Reproduced:3 of 3 (100.0%)
Same Version:3 (100.0%)
Same OS:3 (100.0%)
From: gilad dot buzi at concatel dot com Assigned:
Status: Closed Package: Filesystem function related
PHP Version: 5CVS, 4CVS (2005-03-06) OS: win32 only
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: gilad dot buzi at concatel dot com
New email:
PHP Version: OS:

 

 [2004-12-30 10:43 UTC] gilad dot buzi at concatel dot com
Description:
------------
is_dir() and is_file() (incorrectly) return true for any string larger than 255 characters.

I tried this on two different machines, with the out of the box, precompiled/downloaded Windows version of php 5.0.3.  No changes were made to the standard php.ini-dist.  No extra extensions were loaded.  We are using PHP as an Apache2 module (php2apache2.dll).  We also tried the latest CVS snapshot (5CVS-2004-12-30 (dev)) and got the same results. 

We tried, and could NOT reproduce this on Linux.  It only failed on windows platforms.  

Curiously (or maybe not so curious), file_exists() DOES work fine. 

Reproduce code:
---------------
<?
$myfilename="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaccccccccccccccccccccccccccsssssssssssssssssssssssssssssssssssssssssssssaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaccccccccccccccccccccccccccssssssssssssssssssssssssssssssssssssssssssssss";
echo "myfilename is: $myfilename";
echo "<br>myfilename is ".strlen($myfilename)." characters long";
echo "<br>is_dir: ".is_dir($myfilename);
echo "<br>file_exists: ".file_exists($myfilename);
echo "<br>is_file: ".is_file($myfilename);

$myfilename="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaccccccccccccccccccccccccccsssssssssssssssssssssssssssssssssssssssssssssaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaccccccccccccccccccccccccccssssssssssssssssssssssssssssssssssssssssssssss";
echo "<br><br>myfilename is: $myfilename";
echo "<br>myfilename is ".strlen($myfilename)." characters long";
echo "<br>is_dir: ".is_dir($myfilename);
echo "<br>file_exists: ".file_exists($myfilename);
echo "<br>is_file: ".is_file($myfilename);
?>

Expected result:
----------------
is_dir() and is_file() should return false if the file or directory does not exist, regardless of the length of the string they are passed.



Actual result:
--------------
Result for above script is:
myfilename is: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaccccccccccccccccccccccccccsssssssssssssssssssssssssssssssssssssssssssssaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaccccccccccccccccccccccccccssssssssssssssssssssssssssssssssssssssssssssss
myfilename is 255 characters long
is_dir:
file_exists:
is_file:

myfilename is: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaccccccccccccccccccccccccccsssssssssssssssssssssssssssssssssssssssssssssaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaccccccccccccccccccccccccccssssssssssssssssssssssssssssssssssssssssssssss
myfilename is 256 characters long
is_dir: 1
file_exists: 1
is_file:

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-02-20 16:21 UTC] smith at backendmedia dot com
You can add file_exists() to the list of functions that have this error. I tested this with php4-win32-STABLE-200502081330.zip
 [2005-02-22 15:52 UTC] iliaa@php.net
Win32 specific bug, due to the stat() function not having handling in place for filenames >255 chars.
 [2005-10-11 05:45 UTC] nunbot at gmail dot com
I've seen this in 5.0.4 build 2600 using win32. Unfortunately the string length does not seem to matter at all on both is_dir() and is_file().
~nunbot
 [2005-12-20 15:28 UTC] iliaa@php.net
This bug has been fixed in CVS.

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/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 13 02:01:27 2024 UTC