php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75679 Path 260 character problem
Submitted: 2017-12-13 23:34 UTC Modified: -
From: r dot wagler at gmx dot net Assigned:
Status: Closed Package: Filesystem function related
PHP Version: 7.2.0 OS: Windows 8.1 Pro
Private report: No CVE-ID: None
 [2017-12-13 23:34 UTC] r dot wagler at gmx dot net
Description:
------------
Function copy () can not handle files with pathes of strlen () == 260 characters.

Pathes with less or more then 260 characters are *not* affected.

---

> The version number of the PHP package or files you are using.
http://windows.php.net/downloads/releases/php-7.2.0-nts-Win32-VC15-x64.zip

> Any changes made in your php.ini compared to php.ini-dist or php.ini-recommended (not your whole php.ini!)
I made a clean copy of php.ini-production (copy php.ini-production php.ini).

Test script:
---------------
<?PHP
$Files2Report =
 [
  str_pad ('C:/TEMP/' . str_repeat (str_pad ('path_259_characters_long_' . microtime (true), 100, '_') . '/', 2), 259, '_') => [],
  str_pad ('C:/TEMP/' . str_repeat (str_pad ('path_260_characters_long_' . microtime (true), 100, '_') . '/', 2), 260, '_') => [],
  str_pad ('C:/TEMP/' . str_repeat (str_pad ('path_261_characters_long_' . microtime (true), 100, '_') . '/', 2), 261, '_') => [],
 ];
foreach ($Files2Report as $file => &$Report)
 {
  $Report = ['strlen' => strlen ($file), 'result' => 'nok'];

  if (! is_dir (dirname ($file))) mkdir (dirname ($file), 0777, true);
  if (@copy (__FILE__, $file) && is_file ($file))
   {
    $Report['result'] = 'ok';
   }

  print_r ($Report);
 }
//print_r ([$Files2Report, phpversion ()]);
?>

Expected result:
----------------
Array
(
    [strlen] => 259
    [result] => ok
)
Array
(
    [strlen] => 260
    [result] => ok
)
Array
(
    [strlen] => 261
    [result] => ok
)

Actual result:
--------------
Array
(
    [strlen] => 259
    [result] => ok
)
PHP Warning:  copy(C:/TEMP/path_260_characters_long_1513207625.2858____________________________________________________________/path_260_characters_long_1513207625.2858____________________________________________________________/__________________________________________________): failed to open stream: No such file or directory in ...\path_260_character_problem.php on line 13
Array
(
    [strlen] => 260
    [result] => nok
)
Array
(
    [strlen] => 261
    [result] => ok
)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-12-14 15:18 UTC] ab@php.net
Automatic comment on behalf of ab
Revision: http://git.php.net/?p=php-src.git;a=commit;h=4c0af1fbd41761524682f59c96f2c49e0257298c
Log: Fixed bug #75679 Path 260 character problem
 [2017-12-14 15:18 UTC] ab@php.net
-Status: Open +Status: Closed
 
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Mon Nov 19 00:01:25 2018 UTC