From a91afd46d61aaec1da65d1d5807ae1217554479f Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 18 Feb 2015 11:07:17 +0000 Subject: [PATCH] Prevent scp-style arguments from being mangled An argument like me@example.com:/tmp/ is not something we should convert into a Windows path; Use the absence of a slash before the colon as a tell-tale that it is *not* a POSIX path list (exception: if the part left of the colon is "." or ".."). Signed-off-by: Johannes Schindelin --- winsup/cygwin/msys2_path_conv.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/winsup/cygwin/msys2_path_conv.cc b/winsup/cygwin/msys2_path_conv.cc index c30babf704..c6f5f71764 100644 --- a/winsup/cygwin/msys2_path_conv.cc +++ b/winsup/cygwin/msys2_path_conv.cc @@ -462,6 +462,8 @@ path_type find_path_start_and_type(const char** src, int recurse, const char* en int starts_with_minus = 0; int starts_with_minus_alpha = 0; + int only_dots = *it == '.'; + int has_slashes = 0; if (*it == '-') { starts_with_minus = 1; it += 1; @@ -505,11 +507,17 @@ path_type find_path_start_and_type(const char** src, int recurse, const char* en if (ch == '/' && *(it2 + 1) == '/') { return URL; } else { + if (!only_dots && !has_slashes) + goto skip_p2w; return POSIX_PATH_LIST; } } else if (memchr(it2, '=', end - it2) == NULL) { return SIMPLE_WINDOWS_PATH; } + } else if (ch != '.') { + only_dots = 0; + if (ch == '/' || ch == '\\') + has_slashes = 1; } }