mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-03-22 14:39:24 -05:00
Prevent wildcards in source specs from matching . or ..
[originally from svn r813]
This commit is contained in:
parent
d75f3687fb
commit
b9c07ac266
21
scp.c
21
scp.c
@ -1003,6 +1003,27 @@ static void toremote(int argc, char *argv[])
|
|||||||
do {
|
do {
|
||||||
char *last;
|
char *last;
|
||||||
char namebuf[2048];
|
char namebuf[2048];
|
||||||
|
/*
|
||||||
|
* Ensure that . and .. are never matched by wildcards,
|
||||||
|
* but only by deliberate action.
|
||||||
|
*/
|
||||||
|
if (!strcmp(fdat.cFileName, ".") ||
|
||||||
|
!strcmp(fdat.cFileName, "..")) {
|
||||||
|
/*
|
||||||
|
* Find*File has returned a special dir. We require
|
||||||
|
* that _either_ `src' ends in a backslash followed
|
||||||
|
* by that string, _or_ `src' is precisely that
|
||||||
|
* string.
|
||||||
|
*/
|
||||||
|
int len = strlen(src), dlen = strlen(fdat.cFileName);
|
||||||
|
if (len == dlen && !strcmp(src, fdat.cFileName)) {
|
||||||
|
/* ok */;
|
||||||
|
} else if (len > dlen+1 && src[len-dlen-1] == '\\' &&
|
||||||
|
!strcmp(src+len-dlen, fdat.cFileName)) {
|
||||||
|
/* ok */;
|
||||||
|
} else
|
||||||
|
continue; /* ignore this one */
|
||||||
|
}
|
||||||
if (strlen(src) + strlen(fdat.cFileName) >=
|
if (strlen(src) + strlen(fdat.cFileName) >=
|
||||||
sizeof(namebuf)) {
|
sizeof(namebuf)) {
|
||||||
tell_user(stderr, "%s: Name too long", src);
|
tell_user(stderr, "%s: Name too long", src);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user