summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/path.cc
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2009-05-28 05:10:03 +0000
committerChristopher Faylor <me@cgf.cx>2009-05-28 05:10:03 +0000
commit9971adf5aaeb9e0f7f50e00f3ae07f18a72712a4 (patch)
treedc3bd39ccc340bb00e6c6602a71eb0036127822e /winsup/cygwin/path.cc
parent0072a411295961e3b0601e7a3a9d91250e35edd5 (diff)
downloadcygnal-9971adf5aaeb9e0f7f50e00f3ae07f18a72712a4.tar.gz
cygnal-9971adf5aaeb9e0f7f50e00f3ae07f18a72712a4.tar.bz2
cygnal-9971adf5aaeb9e0f7f50e00f3ae07f18a72712a4.zip
* path.cc (cwdstuff::set): Avoid removing a nonexistent trailing slash.
Diffstat (limited to 'winsup/cygwin/path.cc')
-rw-r--r--winsup/cygwin/path.cc13
1 files changed, 8 insertions, 5 deletions
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index ca2df5872..d3af3bcc1 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -3180,8 +3180,9 @@ cwdstuff::set (PUNICODE_STRING nat_cwd, const char *posix_cwd, bool doit)
pdir->Length + 2);
RtlCopyUnicodeString (&win32, pdir);
RtlReleasePebLock ();
- /* Remove trailing slash. */
- if (win32.Length > 3 * sizeof (WCHAR))
+ /* Remove trailing slash if one exists. FIXME: Is there a better way to
+ do this? */
+ if (win32.Length > 3 * sizeof (WCHAR) && win32.Buffer[win32.Length - 1] == L'\\')
win32.Length -= sizeof (WCHAR);
posix_cwd = NULL;
}
@@ -3197,15 +3198,17 @@ cwdstuff::set (PUNICODE_STRING nat_cwd, const char *posix_cwd, bool doit)
upath.Buffer[0] = L'\\';
upath.Length = len * sizeof (WCHAR);
}
- else if (upath.Length > 3 * sizeof (WCHAR))
- upath.Length -= sizeof (WCHAR); /* Strip trailing backslash */
+ /* Remove trailing slash if one exists. FIXME: Is there a better way to
+ do this? */
+ else if (upath.Length > 3 * sizeof (WCHAR) && upath.Buffer[upath.Length] == L'\\')
+ upath.Length -= sizeof (WCHAR);
RtlInitEmptyUnicodeString (&win32,
(PWCHAR) crealloc_abort (win32.Buffer,
upath.Length + 2),
upath.Length + 2);
RtlCopyUnicodeString (&win32, &upath);
}
- /* Make sure it's NUL-termniated. */
+ /* Make sure it's NUL-terminated. */
win32.Buffer[win32.Length / sizeof (WCHAR)] = L'\0';
if (!doit) /* Virtual path */
drive_length = 0;