|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #38276 file_exists works incorrectly with long filenames
Submitted: 2006-07-31 21:32 UTC Modified: 2006-08-05 17:15 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: bjoernhaeuser at googlemail dot com Assigned:
Status: Closed Package: Filesystem function related
PHP Version: 5.2. (latest) OS: Windows
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
24 + 47 = ?
Subscribe to this entry?

 [2006-07-31 21:32 UTC] bjoernhaeuser at googlemail dot com
Hey Guys!

Relating to:
This Bug seems to be not fixed.

Reproduce code:
D:\>php -r "var_dump(file_exists(str_repeat('a', 10000)));"
D:\>php -r "var_dump(file_exists(str_repeat('a', 255)));"

Expected result:
file_exists should return false in both cases.

Actual result:
D:\>php -r "var_dump(file_exists(str_repeat('a', 10000)));"

D:\>php -r "var_dump(file_exists(str_repeat('a', 255)));"


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-07-31 21:42 UTC]
Please try using this CVS snapshot:
For Windows:

 [2006-08-03 13:56 UTC] bjoernhaeuser at googlemail dot com
Sorry for my late answer.

I am getting this with the latest snapshot: 

D:\php5.2-win32-latest>php -v
PHP 5.2.0RC2-dev (cli) (built: Aug  3 2006 12:21:14)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2006 Zend Technologies

D:\php5.2-win32-latest>php -r "var_dump(file_exists(str_repeat('a', 10000)));"

D:\php5.2-win32-latest>php -r "var_dump(file_exists(str_repeat('a', 255)));"

file_exists works here totally incorrect.

Yours sincerely
 [2006-08-03 14:06 UTC] bjoernhaeuser at googlemail dot com
I have just checked some more and found this: 

D:\php5.2-win32-latest>php -r "var_dump(file_exists(str_repeat('a', 236)));"

D:\php5.2-win32-latest>php -r "var_dump(file_exists(str_repeat('a', 237)));"

file_exists works here incorrectly with filenames > 236

Yours sincerely
 [2006-08-03 14:18 UTC]
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
Thank you for the report, and for helping us make PHP better.

 [2006-08-04 13:49 UTC] bjoernhaeuser at googlemail dot com
Well I am getting this: 

D:\php5.2-cvs>php -v
PHP 5.2.0RC2-dev (cli) (built: Aug  4 2006 12:21:08)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2006 Zend Technologies

D:\php5.2-cvs>php -r "var_dump(file_exists(str_repeat('a', 246)));"

D:\php5.2-cvs>php -r "var_dump(file_exists(str_repeat('a', 245)));"

So, its not fixed.
 [2006-08-04 15:05 UTC]
Does 4.4.3 work for you?
 [2006-08-04 17:20 UTC] bjoernhaeuser at googlemail dot com
D:\php4.3\cli>php -r "var_dump(file_exists(str_repeat('a', 260)));"

Warning: file_exists(): Stat failed for aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa (errno=0 - No error
) in Command line code on line 1

D:\php4.3\cli>php -r "var_dump(file_exists(str_repeat('a', 255)));"

Works 'correctly' for me.
 [2006-08-05 13:19 UTC]
Please try next Win32 snapshot, it should work fine.
 [2006-08-05 17:15 UTC] bjoernhaeuser at googlemail dot com
Yes works.
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Wed May 27 07:01:27 2020 UTC