Bug #73971 [Opn]: Filename got limited to MAX_PATH on Win32 when scan directory
| From: | ademybiz at gmail dot com | Date: | Sun, 22 Jan 2017 06:47:21 +0000 |
| Subject: | Bug #73971 [Opn]: Filename got limited to MAX_PATH on Win32 when scan directory | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-206844@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=73971&edit=1
ID: 73971
User updated by: ademybiz at gmail dot com
Reported by: ademybiz at gmail dot com
-Summary: Filename get limited to MAX_PATH on Win32 when scan
directory
+Summary: Filename got limited to MAX_PATH on Win32 when scan
directory
Status: Open
Type: Bug
Package: *Directory/Filesystem functions
Operating System: Windows 10(10586)
PHP Version: 7.1.1
Block user comment: N
Private report: N
New Comment:
PHP 7.1.1 (cli) (built: Jan 18 2017 18:38:28) ( NTS MSVC14 (Visual C++ 2015) x64 )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.1.1, Copyright (c) 1999-2017, by Zend Technologies
Previous Comments:
------------------------------------------------------------------------
[2017-01-22 06:47:01] ademybiz at gmail dot com
PHP 7.1.1 (cli) (built: Jan 18 2017 18:38:28) ( NTS MSVC14 (Visual C++ 2015) x64 )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.1.1, Copyright (c) 1999-2017, by Zend Technologies
------------------------------------------------------------------------
[2017-01-22 06:45:00] ademybiz at gmail dot com
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 this bug report at https://bugs.php.net/bug.php?id=73971&edit=1