From 66019dbead11137ab3184dc0837f7c7ef92245b7 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 2 Jan 2024 14:38:33 -0800 Subject: Fix broken handling of drive relative paths. * winsup/cygwin/path.cc (normalize_win32_path): Fix bungled logic for replacing a relative drive reference with the working directory from that drive. We were wrongly copying an extra drive letter character. --- winsup/cygwin/path.cc | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index 807a7c6ef..83718385d 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -1483,8 +1483,13 @@ normalize_win32_path (const char *src, char *dst, char *&tail) /* Always convert drive letter to uppercase for case sensitivity. */ if (isdirsep (src[2])) - /* Always convert drive letter to uppercase for case sensitivity. */ - *tail++ = cyg_toupper (*src++); + { + /* Always convert drive letter to uppercase for case sensitivity. */ + *tail++ = cyg_toupper (*src++); + *tail++ = *src++; + *tail++ = *src++; + dst = tail; + } else { /* Drive-relative path: get drive path from environment. */ @@ -1499,19 +1504,18 @@ normalize_win32_path (const char *src, char *dst, char *&tail) return ENAMETOOLONG; tail += len; + dst = tail; *tail++ = '\\'; src += 2; } else { *tail++ = cyg_toupper (*src++); + *tail++ = *src++; + dst = tail; + *tail++ = '\\'; } } - *tail++ = *src++; - dst = tail; - /* If backslash is missing in src, add one. */ - if (!isdirsep (src[0])) - *tail++ = '\\'; } else { -- cgit v1.2.3