diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index f82ef0404..a892c0207 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,7 @@ +2009-05-28 Christopher Faylor + + * path.cc (cwdstuff::set): Avoid removing a nonexistent trailing slash. + 2009-05-20 Eric Blake * net.cc (gethostby_helper): Use correct signedness. diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc index b66575cba..4260b20e0 100644 --- a/winsup/cygwin/net.cc +++ b/winsup/cygwin/net.cc @@ -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; } 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;