From 6d71fcf106140ad70cd0f6fd4484a5128946798b Mon Sep 17 00:00:00 2001 From: corinna Date: Wed, 15 Jul 2009 13:27:34 +0000 Subject: [PATCH] * path.cc (cwdstuff::set): Only fix up UNC path in win32 so as not to overwrite incoming path. --- winsup/cygwin/ChangeLog | 5 +++++ winsup/cygwin/path.cc | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 9883f3b24a..8f477c8a93 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,8 @@ +2009-07-15 Corinna Vinschen + + * path.cc (cwdstuff::set): Only fix up UNC path in win32 so as not + to overwrite incoming path. + 2009-07-14 Corinna Vinschen Throughout avoid having to initialize constant UNICODE_STRINGs. diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index b8be19f2e1..20d750303a 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -3195,6 +3195,8 @@ cwdstuff::set (PUNICODE_STRING nat_cwd, const char *posix_cwd, bool doit) } else { + bool unc = false; + if (upath.Buffer[0] == L'/') /* Virtual path, don't mangle. */ ; else if (!doit) @@ -3202,7 +3204,7 @@ cwdstuff::set (PUNICODE_STRING nat_cwd, const char *posix_cwd, bool doit) /* Convert to a Win32 path. */ upath.Buffer += upath.Length / sizeof (WCHAR) - len; if (upath.Buffer[1] == L'\\') /* UNC path */ - upath.Buffer[0] = L'\\'; + unc = true; upath.Length = len * sizeof (WCHAR); } else @@ -3218,6 +3220,8 @@ cwdstuff::set (PUNICODE_STRING nat_cwd, const char *posix_cwd, bool doit) upath.Length + 2), upath.Length + 2); RtlCopyUnicodeString (&win32, &upath); + if (unc) + win32.Buffer[0] = L'\\'; } /* Make sure it's NUL-terminated. */ win32.Buffer[win32.Length / sizeof (WCHAR)] = L'\0'; -- 2.11.0