--- ./cygwin-2.10.0-1.src/newlib-cygwin/winsup/cygwin/path.cc.ORIG 2018-05-03 19:43:00.482472100 -0400 +++ ./cygwin-2.10.0-1.src/newlib-cygwin/winsup/cygwin/path.cc 2018-05-03 20:09:44.035630700 -0400 @@ -1342,6 +1342,7 @@ int normalize_win32_path (const char *src, char *dst, char *&tail) { + int drvprefixlen = 0; const char *src_start = src; bool beg_src_slash = isdirsep (src[0]); @@ -1385,9 +1386,10 @@ *tail++ = cyg_toupper (*src++); else if (*src != '/') { - if (beg_src_slash) - tail += cygheap->cwd.get_drive (dst); - else if (!cygheap->cwd.get (dst, 0)) + if (beg_src_slash) { + drvprefixlen = cygheap->cwd.get_drive (dst); + tail += drvprefixlen; + } else if (!cygheap->cwd.get (dst, 0)) return get_errno (); else { @@ -1423,10 +1425,10 @@ else { /* Back up over /, but not if it's the first one. */ - if (tail > dst + 1) + if (tail > dst + 1 + drvprefixlen) tail--; /* Now back up to the next /. */ - while (tail > dst + 1 && tail[-1] != '\\' && tail[-2] != ':') + while (tail > dst + 1 + drvprefixlen && tail[-1] != '\\' && tail[-2] != ':') tail--; src += 2; /* Skip /'s to the next path component. */ @@ -1446,7 +1448,7 @@ if ((tail - dst) >= NT_MAX_PATH) return ENAMETOOLONG; } - if (tail > dst + 1 && tail[-1] == '.' && tail[-2] == '\\') + if (tail > dst + 1 + drvprefixlen && tail[-1] == '.' && tail[-2] == '\\') tail--; *tail = '\0'; debug_printf ("%s = normalize_win32_path (%s)", dst, src_start); @@ -2800,7 +2802,7 @@ if (*p != '.' && *p != ' ') { while (*--p != '\\') - ; + assert(p >= path); if (*++p != ' ') p = NULL; }