From: gilad dot buzi at concatel dot com
Operating system: Windows (2000/XP)
PHP version: 5.0.3
PHP Bug Type: *Directory/Filesystem functions
Bug description: is_dir and is_file (incorrectly) return true for any string > 255 characters
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 bug report at http://bugs.php.net/?id=31347&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=31347&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=31347&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=31347&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=31347&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=31347&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=31347&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=31347&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=31347&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=31347&r=support
Expected behavior: http://bugs.php.net/fix.php?id=31347&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=31347&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=31347&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=31347&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=31347&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=31347&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=31347&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=31347&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=31347&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=31347&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=31347&r=mysqlcfg