From 90b695c255eeeddb2bb90e5cacbd3253663bfa7f Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Tue, 30 Jun 2020 15:44:20 +0100 Subject: ash: improve handling of UNC paths Be more strict about identifying UNC paths in unc_root_len(). In updatepwd() in ash: - Skip duplicate leading slashes unless the directory is a UNC path. - Rewrite detection and handling of the five possible types of path. This improves cases like 'cd ///' and 'cd /xyz' when the current directory is a UNC path. See GitHub issue #192. --- win32/mingw.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'win32') diff --git a/win32/mingw.c b/win32/mingw.c index 06b22a2ed..78d662e50 100644 --- a/win32/mingw.c +++ b/win32/mingw.c @@ -1643,7 +1643,8 @@ void hide_console(void) #endif #define is_path_sep(x) ((x) == '/' || (x) == '\\') -#define is_unc_path(x) (is_path_sep(x[0]) && is_path_sep(x[1])) +#define is_unc_path(x) (strlen(x) > 4 && is_path_sep(x[0]) && \ + is_path_sep(x[1]) && !is_path_sep(x[2])) /* Return the length of the root of a UNC path, i.e. the '//host/share' * component, or 0 if the path doesn't look like that. */ -- cgit v1.2.3-55-g6feb