diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index e56a08f77b..2d18cd21cd 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -709,6 +709,12 @@ path_conv::check (const char *src, unsigned opt, need_directory = 1; *--tail = '\0'; } + /* Special case for "/" must set need_directory, without removing + trailing slash */ + else if (tail == path_copy + 1 && isslash (tail[-1])) + { + need_directory = 1; + } path_end = tail; /* Scan path_copy from right to left looking either for a symlink @@ -1248,6 +1254,7 @@ path_conv::check (const char *src, unsigned opt, cfree (wide_path); wide_path = NULL; } + if (need_directory) { size_t n = strlen (this->path);