Skip to content

Commit ca0293f

Browse files
committed
Prevent scp-style arguments from being mangled
An argument like [email protected]:/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 <[email protected]>
1 parent 0c0eac8 commit ca0293f

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

winsup/cygwin/msys2_path_conv.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,8 @@ path_type find_path_start_and_type(const char** src, int recurse, const char* en
449449

450450
int starts_with_minus = 0;
451451
int starts_with_minus_alpha = 0;
452+
int only_dots = *it == '.';
453+
int has_slashes = 0;
452454
if (*it == '-') {
453455
starts_with_minus = 1;
454456
it += 1;
@@ -489,11 +491,17 @@ path_type find_path_start_and_type(const char** src, int recurse, const char* en
489491
if (ch == '/' && *(it2 + 1) == '/') {
490492
return URL;
491493
} else {
494+
if (!only_dots && !has_slashes)
495+
goto skip_p2w;
492496
return POSIX_PATH_LIST;
493497
}
494498
} else if (memchr(it2, '=', end - it) == NULL) {
495499
return SIMPLE_WINDOWS_PATH;
496500
}
501+
} else if (ch != '.') {
502+
only_dots = 0;
503+
if (ch == '/' || ch == '\\')
504+
has_slashes = 1;
497505
}
498506
}
499507

0 commit comments

Comments
 (0)