* path.cc (cwdstuff::set): Avoid removing a nonexistent trailing slash.

This commit is contained in:
Christopher Faylor 2009-05-28 05:10:03 +00:00
parent 0072a41129
commit 9971adf5aa
3 changed files with 12 additions and 7 deletions

View File

@ -1,3 +1,7 @@
2009-05-28 Christopher Faylor <me+cygwin@cgf.cx>
* path.cc (cwdstuff::set): Avoid removing a nonexistent trailing slash.
2009-05-20 Eric Blake <ebb9@byu.net>
* net.cc (gethostby_helper): Use correct signedness.

View File

@ -63,7 +63,6 @@ extern "C"
const char *cygwin_inet_ntop (int, const void *, char *, socklen_t);
int dn_length1(const unsigned char *, const unsigned char *,
const unsigned char *);
} /* End of "C" section */
const struct in6_addr in6addr_any = {{IN6ADDR_ANY_INIT}};
@ -119,7 +118,6 @@ inet_netof (struct in_addr in)
else
res = (i & IN_CLASSC_NET) >> IN_CLASSC_NSHIFT;
return res;
}

View File

@ -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;