Bug #73971 [NEW]: Filename get limited to MAX_PATH on Win32 when scan directory
| From: | ademybiz at gmail dot com | Date: | Sun, 22 Jan 2017 06:45:07 +0000 |
| Subject: | Bug #73971 [NEW]: Filename get limited to MAX_PATH on Win32 when scan directory | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-206842@lists.php.net to get a copy of this message | ||
From: ademybiz at gmail dot com
Operating system: Windows
PHP version: 7.1.1
Package: *Directory/Filesystem functions
Bug Type: Bug
Bug description:Filename get limited to MAX_PATH on Win32 when scan directory
Description:
------------
It is awesome that PHP7.1 implemented Unicode file APIs on Windows as
http://git.php.net/?p=php-src.git;a=commit;h=3d3f11ede4cc7c83d64cc5edaae7c29ce9c6986f.
There is likely one thing we left: PHP can create long file names but
structs to store directory enumeration are still 256-byte as MAX_PATH
defined.
It is natural when the filename is less than 256 ASCII glyph. But I can
create multibyte filename up to 256 glyph while can not be accessed
again because the actual length is over 256 bytes.
Function scandir() behaves similarly.
Test script:
---------------
<?php
$filename = str_repeat('ãã¹ã', 48); // 144 glyph here, less than
256
var_dump($filename); // 432 bytes here, more than 256
mkdir(__DIR__ . '\\' . $filename); // created correctly
$d = dir(__DIR__);
while (false !== ($entry = $d->read())) {
var_dump($entry);
}
$d->close();
Expected result:
----------------
string(432)
"ãã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ã"
string(1) "."
string(2) ".."
string(5) "1.php"
string(5) "1.txt"
string(432)
"ãã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ã"
Actual result:
--------------
string(432)
"ãã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ã"
string(1) "."
string(2) ".."
string(5) "1.php"
string(5) "1.txt"
string(256)
"ãã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ããã¹ãã"
// truncated by 0xE5
--
Edit bug report at https://bugs.php.net/bug.php?id=73971&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=73971&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=73971&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=73971&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=73971&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=73971&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=73971&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=73971&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=73971&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=73971&r=support
Expected behavior: https://bugs.php.net/fix.php?id=73971&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=73971&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=73971&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=73971&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=73971&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=73971&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=73971&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=73971&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=73971&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=73971&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=73971&r=mysqlcfg