From: Anatol Belski Date: Fri, 20 Jan 2017 22:45:08 +0000 (+0100) Subject: Fixed bug #73962 bug with symlink related to cyrillic directory X-Git-Tag: php-7.1.2RC1~40 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=95406c878a9cc25ad1e831e619afba683e92f05a;p=php Fixed bug #73962 bug with symlink related to cyrillic directory --- diff --git a/NEWS b/NEWS index 65856c647d..baed4466b7 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,7 @@ PHP NEWS . Fixed bug #73877 (readlink() returns garbage for UTF-8 paths). (Anatol) . Fixed bug #73876 (Crash when exporting **= in expansion of assign op). (Sara) + . Fixed bug #73962 (bug with symlink related to cyrillic directory). (Anatol) - DTrace: . Fixed bug #73965 (DTrace reported as enabled when disabled). (Remi) diff --git a/Zend/zend_virtual_cwd.c b/Zend/zend_virtual_cwd.c index 53343482db..9c2dc29299 100644 --- a/Zend/zend_virtual_cwd.c +++ b/Zend/zend_virtual_cwd.c @@ -914,7 +914,7 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i wchar_t * reparsetarget; BOOL isVolume = FALSE; char *printname = NULL, *substitutename = NULL; - int substitutename_len; + size_t substitutename_len; int substitutename_off = 0; if(++(*ll) > LINK_MAX) { @@ -959,7 +959,8 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i } substitutename_len = pbuffer->MountPointReparseBuffer.SubstituteNameLength / sizeof(WCHAR); - substitutename = php_win32_ioutil_w_to_any(reparsetarget + pbuffer->MountPointReparseBuffer.SubstituteNameOffset / sizeof(WCHAR)); + substitutename = php_win32_cp_conv_w_to_any(reparsetarget + pbuffer->MountPointReparseBuffer.SubstituteNameOffset / sizeof(WCHAR), + substitutename_len, &substitutename_len); if (!substitutename) { free_alloca(pbuffer, use_heap_large); free_alloca(tmp, use_heap); @@ -981,7 +982,8 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i substitutename_len = pbuffer->MountPointReparseBuffer.SubstituteNameLength / sizeof(WCHAR); - substitutename = php_win32_ioutil_w_to_any(reparsetarget + pbuffer->MountPointReparseBuffer.SubstituteNameOffset / sizeof(WCHAR)); + substitutename = php_win32_cp_conv_w_to_any(reparsetarget + pbuffer->MountPointReparseBuffer.SubstituteNameOffset / sizeof(WCHAR), + substitutename_len, &substitutename_len); if (!substitutename) { free_alloca(pbuffer, use_heap_large); free_alloca(tmp, use_heap); diff --git a/ext/standard/tests/file/windows_links/bug73962.phpt b/ext/standard/tests/file/windows_links/bug73962.phpt new file mode 100644 index 0000000000..6d578386e6 --- /dev/null +++ b/ext/standard/tests/file/windows_links/bug73962.phpt @@ -0,0 +1,77 @@ +--TEST-- +Bug #73962 bug with symlink related to cyrillic directory +--SKIPIF-- +&1', $out); +if (strpos($ret, 'privilege')) { + die('skip. SeCreateSymbolicLinkPrivilege not enable for this user.'); +} +unlink('bug48746_tmp.lnk'); +?> +--FILE-- +"); +file_put_contents("$fullpath\\mnt\\test\\новая папка\\b.php", ""); +var_dump(scandir("mklink_symlink")); +var_dump(scandir("$fullpath\\mnt\\test\\новая папка")); +var_dump(scandir("$fullpath\\mnt\\test\\mklink_symlink")); +var_dump(is_readable("$fullpath\\mnt\\test\\mklink_symlink\b.php")); +unlink("$fullpath\\mnt\\test\\новая папка\\b.php"); +unlink("mklink_symlink\\a.php"); +chdir($old_dir); +rmdir(__DIR__ . "\\mnt\\test\\новая папка"); +rmdir(__DIR__ . "\\mnt\\test\\mklink_symlink"); +rmdir(__DIR__ . "\\mnt\\test\\mounted_volume"); +rmdir(__DIR__ . "\\mnt\\test"); +rmdir(__DIR__ . "\\mnt"); + +?> +--EXPECT-- +array(4) { + [0]=> + string(1) "." + [1]=> + string(2) ".." + [2]=> + string(5) "a.php" + [3]=> + string(5) "b.php" +} +array(4) { + [0]=> + string(1) "." + [1]=> + string(2) ".." + [2]=> + string(5) "a.php" + [3]=> + string(5) "b.php" +} +array(4) { + [0]=> + string(1) "." + [1]=> + string(2) ".." + [2]=> + string(5) "a.php" + [3]=> + string(5) "b.php" +} +bool(true) +