diff options
Diffstat (limited to 'winsup/cygwin/path.cc')
-rw-r--r-- | winsup/cygwin/path.cc | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index f2b56cf1f..8fc616ef4 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -955,18 +955,26 @@ out: { if (strncmp (path, "\\\\.\\", 4)) { - /* Windows ignores trailing dots and spaces */ + /* Windows ignores trailing dots and spaces in the last path + component, and ignores exactly one trailing dot in inner + path components. */ char *tail = NULL; for (char *p = path; *p; p++) - if (*p != '.' && *p != ' ') - tail = NULL; - else if (p[1] == '\\') - { - memmove (p, p + 1, strlen (p)); + { + if (*p != '.' && *p != ' ') tail = NULL; - } - else if (!tail) - tail = p; + else if (!tail) + tail = p; + if (tail && p[1] == '\\') + { + if (p > tail || *tail != '.') + { + error = ENOENT; + return; + } + tail = NULL; + } + } if (!tail || tail == path) /* nothing */; |