[PATCH] ntdll: Properly set the current directory for UNC paths

Gabriel Iv─âncescu gabrielopcode at gmail.com
Thu Aug 23 09:14:18 CDT 2018


Most of the other code deals with UNC paths of the form \\server\share
in the current directory, which is proper, but the current directory is
wrongfully set to the form UNC\server\share, so fix it.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=37834
Signed-off-by: Gabriel Iv─âncescu <gabrielopcode at gmail.com>
---
 dlls/ntdll/path.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/dlls/ntdll/path.c b/dlls/ntdll/path.c
index ccc95e3..6291f9d 100644
--- a/dlls/ntdll/path.c
+++ b/dlls/ntdll/path.c
@@ -1039,12 +1039,22 @@ NTSTATUS WINAPI RtlSetCurrentDirectory_U(const UNICODE_STRING* dir)
     if (curdir->Handle) NtClose( curdir->Handle );
     curdir->Handle = handle;
 
-    /* append trailing \ if missing */
     size = newdir.Length / sizeof(WCHAR);
     ptr = newdir.Buffer;
     ptr += 4;  /* skip \??\ prefix */
     size -= 4;
-    if (size && ptr[size - 1] != '\\') ptr[size++] = '\\';
+    if (size)
+    {
+        /* append trailing \ if missing */
+        if (ptr[size - 1] != '\\') ptr[size++] = '\\';
+
+        /* convert \??\UNC\ path to \\ prefix */
+        if (size >= 4 && !strncmpiW(ptr, UncPfxW, 4))
+        {
+            ptr += 4-2; size -= 4-2;
+            *ptr = '\\';
+        }
+    }
 
     memcpy( curdir->DosPath.Buffer, ptr, size * sizeof(WCHAR));
     curdir->DosPath.Buffer[size] = 0;
-- 
1.9.1




More information about the wine-devel mailing list