php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #37918 file_exists() failes on long filenames (gt 259)
Submitted: 2006-06-26 16:01 UTC Modified: 2006-08-23 15:41 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: mrueegg at metaworx dot ch Assigned: nlopess (profile)
Status: Closed Package: Filesystem function related
PHP Version: 5CVS-2006-06-26 (snap) OS: Windows NT 5.1 build 2600 (WiXP)
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: mrueegg at metaworx dot ch
New email:
PHP Version: OS:

 

 [2006-06-26 16:01 UTC] mrueegg at metaworx dot ch
Description:
------------
on my windows system the function file_exists() returns true whenever the full qualified file path has more than a total of 259 characters.

if the path is relative, the cwd will be prepended and counted (e.g. 260-28=232).

i testet it with the snapshot of today (26-Jun-2006 16:19) as well. plain php.exe, no changes to modules or php.ini. same result.

i use an immaginary filename in the root of 'C:\'. the file obviously does not exist.

refer to http://bugs.php.net/bug.php?id=31347 describing the similar error with strlen > 255.


Reproduce code:
---------------
<?php
echo php_uname();

if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
   echo "Running on Windows with PHP ", phpversion(), "\n";
   $root = "c:".DIRECTORY_SEPARATOR;
} else {
   die("problem could not be reproduced on linux (debian with PHP 5.1.2-1+b1)\n");
}
$max = 260;

$t = $root.str_repeat('x', $max - strlen($root));
var_dump(strlen($t));
var_dump(file_exists($t));

$t = $root.str_repeat('x', $max - strlen($root) - 1);
var_dump(strlen($t));
var_dump(file_exists($t));

echo "\nif no root is given, then cwd is prepended:\n";
var_dump(getcwd().DIRECTORY_SEPARATOR);
var_dump(strlen(getcwd().DIRECTORY_SEPARATOR));
echo "\n";

$t = str_repeat('x', $max - strlen(getcwd().DIRECTORY_SEPARATOR));
var_dump(strlen($t));
var_dump(file_exists($t));

$t = str_repeat('x', $max - strlen(getcwd().DIRECTORY_SEPARATOR) - 1);
var_dump(strlen($t));
var_dump(file_exists($t));


Expected result:
----------------
Windows NT MWXDEV 5.1 build 2600
Running on Windows with PHP 5.1.4
int(260)
bool(false)
int(259)
bool(false)

if no root is given, then cwd is prepended:
string(28) "P:\Programming\xampp\htdocs\"
int(28)

int(232)
bool(false)
int(231)
bool(false)


an exception/warning would also be acceptable. but in case of doubt the function should return false.


Actual result:
--------------
Windows NT MWXDEV 5.1 build 2600
Running on Windows with PHP 5.1.4
int(260)
bool(true)
int(259)
bool(false)

if no root is given, then cwd is prepended:
string(28) "P:\Programming\xampp\htdocs\"
int(28)

int(232)
bool(true)
int(231)
bool(false)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-06-26 16:10 UTC] tony2001@php.net
Nuno, IIRC you fixed the previous one, could you please check this out too?
 [2006-08-14 21:48 UTC] nlopess@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip

I cannot reproduce. Please try the snapshot.
 [2006-08-22 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2006-08-23 15:41 UTC] mrueegg at metaworx dot ch
right, tested today on Windows with PHP 5.2.0RC3-dev (current snapshot) and seems fixed.

thanks anyway.

brgds, martin.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 03 04:01:32 2024 UTC