Skip to content

Commit 73bfa26

Browse files
committed
Merge branch 'PHP-7.1'
* PHP-7.1: Fixed bug #73962 bug with symlink related to cyrillic directory
2 parents 0877839 + 95406c8 commit 73bfa26

File tree

2 files changed

+82
-3
lines changed

2 files changed

+82
-3
lines changed

Zend/zend_virtual_cwd.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,7 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
849849
wchar_t * reparsetarget;
850850
BOOL isVolume = FALSE;
851851
char *printname = NULL, *substitutename = NULL;
852-
int substitutename_len;
852+
size_t substitutename_len;
853853
int substitutename_off = 0;
854854

855855
if(++(*ll) > LINK_MAX) {
@@ -894,7 +894,8 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
894894
}
895895

896896
substitutename_len = pbuffer->MountPointReparseBuffer.SubstituteNameLength / sizeof(WCHAR);
897-
substitutename = php_win32_ioutil_w_to_any(reparsetarget + pbuffer->MountPointReparseBuffer.SubstituteNameOffset / sizeof(WCHAR));
897+
substitutename = php_win32_cp_conv_w_to_any(reparsetarget + pbuffer->MountPointReparseBuffer.SubstituteNameOffset / sizeof(WCHAR),
898+
substitutename_len, &substitutename_len);
898899
if (!substitutename) {
899900
free_alloca(pbuffer, use_heap_large);
900901
free_alloca(tmp, use_heap);
@@ -916,7 +917,8 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
916917

917918

918919
substitutename_len = pbuffer->MountPointReparseBuffer.SubstituteNameLength / sizeof(WCHAR);
919-
substitutename = php_win32_ioutil_w_to_any(reparsetarget + pbuffer->MountPointReparseBuffer.SubstituteNameOffset / sizeof(WCHAR));
920+
substitutename = php_win32_cp_conv_w_to_any(reparsetarget + pbuffer->MountPointReparseBuffer.SubstituteNameOffset / sizeof(WCHAR),
921+
substitutename_len, &substitutename_len);
920922
if (!substitutename) {
921923
free_alloca(pbuffer, use_heap_large);
922924
free_alloca(tmp, use_heap);
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
--TEST--
2+
Bug #73962 bug with symlink related to cyrillic directory
3+
--SKIPIF--
4+
<?php
5+
if(substr(PHP_OS, 0, 3) != 'WIN' ) {
6+
die('skip windows only test');
7+
}
8+
include_once __DIR__ . '/common.inc';
9+
$ret = exec('mklink bug48746_tmp.lnk ' . __FILE__ .' 2>&1', $out);
10+
if (strpos($ret, 'privilege')) {
11+
die('skip. SeCreateSymbolicLinkPrivilege not enable for this user.');
12+
}
13+
unlink('bug48746_tmp.lnk');
14+
?>
15+
--FILE--
16+
<?php
17+
include_once __DIR__ . '/common.inc';
18+
$mountvol = get_mountvol();
19+
$old_dir = __DIR__;
20+
$dirname = '"' . __DIR__ . "\\mnt\\test\\новая папка" . '"';
21+
exec("mkdir " . $dirname, $output, $ret_val);
22+
chdir(__DIR__ . "\\mnt\\test");
23+
$drive = substr(__DIR__, 0, 2);
24+
$pathwithoutdrive = substr(__DIR__, 2);
25+
$ret = exec($mountvol . " " . $drive . " /L", $output, $ret_val);
26+
exec("mklink /d mounted_volume " . $ret, $output, $ret_val);
27+
$fullpath = "mounted_volume" . $pathwithoutdrive;
28+
exec("mklink /d mklink_symlink \"новая папка\"", $output, $ret_val);
29+
file_put_contents("mklink_symlink\\a.php", "<?php echo \"I am included.\n\" ?>");
30+
file_put_contents("$fullpath\\mnt\\test\\новая папка\\b.php", "<?php echo \"I am included.\n\" ?>");
31+
var_dump(scandir("mklink_symlink"));
32+
var_dump(scandir("$fullpath\\mnt\\test\\новая папка"));
33+
var_dump(scandir("$fullpath\\mnt\\test\\mklink_symlink"));
34+
var_dump(is_readable("$fullpath\\mnt\\test\\mklink_symlink\b.php"));
35+
unlink("$fullpath\\mnt\\test\\новая папка\\b.php");
36+
unlink("mklink_symlink\\a.php");
37+
chdir($old_dir);
38+
rmdir(__DIR__ . "\\mnt\\test\\новая папка");
39+
rmdir(__DIR__ . "\\mnt\\test\\mklink_symlink");
40+
rmdir(__DIR__ . "\\mnt\\test\\mounted_volume");
41+
rmdir(__DIR__ . "\\mnt\\test");
42+
rmdir(__DIR__ . "\\mnt");
43+
44+
?>
45+
--EXPECT--
46+
array(4) {
47+
[0]=>
48+
string(1) "."
49+
[1]=>
50+
string(2) ".."
51+
[2]=>
52+
string(5) "a.php"
53+
[3]=>
54+
string(5) "b.php"
55+
}
56+
array(4) {
57+
[0]=>
58+
string(1) "."
59+
[1]=>
60+
string(2) ".."
61+
[2]=>
62+
string(5) "a.php"
63+
[3]=>
64+
string(5) "b.php"
65+
}
66+
array(4) {
67+
[0]=>
68+
string(1) "."
69+
[1]=>
70+
string(2) ".."
71+
[2]=>
72+
string(5) "a.php"
73+
[3]=>
74+
string(5) "b.php"
75+
}
76+
bool(true)
77+

0 commit comments

Comments
 (0)