Skip to content

Commit ed210c1

Browse files
committed
Merge branch 'PHP-7.1' into PHP-7.2
* PHP-7.1: Fixed bug #75679 Path 260 character problem
2 parents 8c36588 + 4c0af1f commit ed210c1

File tree

2 files changed

+67
-1
lines changed

2 files changed

+67
-1
lines changed

ext/standard/tests/file/bug75679.phpt

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
--TEST--
2+
Bug #75679 Path 260 character problem
3+
--FILE--
4+
<?php
5+
$d = dirname(__FILE__);
6+
$Files2Report =
7+
[
8+
str_pad ($d . '/' . str_repeat (str_pad ('bug75679_path_259_characters_long_', 100, '_') . '/', 1), 259, '_') => [],
9+
str_pad ($d . '/' . str_repeat (str_pad ('bug75679_path_260_characters_long_', 100, '_') . '/', 1), 260, '_') => [],
10+
str_pad ($d . '/' . str_repeat (str_pad ('bug75679_path_261_characters_long_', 100, '_') . '/', 1), 261, '_') => [],
11+
];
12+
foreach ($Files2Report as $file => &$Report)
13+
{
14+
$Report = ['strlen' => strlen ($file), 'result' => 'nok'];
15+
16+
if (! is_dir (dirname ($file))) mkdir (dirname ($file), 0777, true);
17+
if (copy (__FILE__, $file) && is_file ($file))
18+
{
19+
$Report['result'] = 'ok';
20+
}
21+
22+
print_r ($Report);
23+
}
24+
25+
26+
?>
27+
==DONE==
28+
--CLEAN--
29+
<?php
30+
$d = dirname(__FILE__);
31+
$Files2Report =
32+
[
33+
str_pad ($d . '/' . str_repeat (str_pad ('bug75679_path_259_characters_long_', 100, '_') . '/', 1), 259, '_') => [],
34+
str_pad ($d . '/' . str_repeat (str_pad ('bug75679_path_260_characters_long_', 100, '_') . '/', 1), 260, '_') => [],
35+
str_pad ($d . '/' . str_repeat (str_pad ('bug75679_path_261_characters_long_', 100, '_') . '/', 1), 261, '_') => [],
36+
];
37+
foreach ($Files2Report as $file => &$Report)
38+
{
39+
if (is_file($file)) {
40+
unlink($file);
41+
}
42+
43+
$d1 = dirname($file);
44+
while ($d1 != $d) {
45+
rmdir($d1);
46+
$d1 = dirname($d1);
47+
}
48+
}
49+
?>
50+
--EXPECT--
51+
Array
52+
(
53+
[strlen] => 259
54+
[result] => ok
55+
)
56+
Array
57+
(
58+
[strlen] => 260
59+
[result] => ok
60+
)
61+
Array
62+
(
63+
[strlen] => 261
64+
[result] => ok
65+
)
66+
==DONE==

win32/ioutil.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ __forceinline static wchar_t *php_win32_ioutil_conv_any_to_w(const char* in, siz
168168
}
169169

170170
/* Only prefix with long if it's needed. */
171-
if (mb_len > _MAX_PATH) {
171+
if (mb_len >= _MAX_PATH) {
172172
size_t new_mb_len;
173173

174174
ret = (wchar_t *) malloc((mb_len + PHP_WIN32_IOUTIL_LONG_PATH_PREFIX_LENW + 1) * sizeof(wchar_t));

0 commit comments

Comments
 (0)