Skip to content

Commit

Permalink
Prevent scp-style arguments from being mangled
Browse files Browse the repository at this point in the history
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 <johannes.schindelin@gmx.de>
  • Loading branch information
dscho committed Sep 6, 2023
1 parent 6ee0976 commit 39910e3
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions winsup/cygwin/msys2_path_conv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,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;
Expand Down Expand Up @@ -498,11 +500,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 - it) == NULL) {
return SIMPLE_WINDOWS_PATH;
}
} else if (ch != '.') {
only_dots = 0;
if (ch == '/' || ch == '\\')
has_slashes = 1;
}
}

Expand Down

0 comments on commit 39910e3

Please sign in to comment.