#31347 [Com]: is_dir and is_file (incorrectly) return true for any string > 255 characters
ID: 31347
Comment by: smith at backendmedia dot com
Reported By: gilad dot buzi at concatel dot com
Status: Open
Bug Type: *Directory/Filesystem functions
Operating System: Windows (2000/XP)
PHP Version: 5.0.3
New Comment:
You can add file_exists() to the list of functions that have this
error. I tested this with php4-win32-STABLE-200502081330.zip
Previous Comments:
------------------------------------------------------------------------
[2004-12-30 10:43:57] 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:
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=31347&edit=1
Thread (5 messages)