From 7f266ffb0159bb122309f788a5cbcf6b2a3a4342 Mon Sep 17 00:00:00 2001 From: simon Date: Thu, 30 Nov 2000 21:35:28 +0000 Subject: [PATCH] Prevent wildcards in source specs from matching . or .. git-svn-id: svn://svn.tartarus.org/sgt/putty@813 cda61777-01e9-0310-a592-d414129be87e --- scp.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/scp.c b/scp.c index 3f85006c..a4c03038 100644 --- a/scp.c +++ b/scp.c @@ -1003,6 +1003,27 @@ static void toremote(int argc, char *argv[]) do { char *last; 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) >= sizeof(namebuf)) { tell_user(stderr, "%s: Name too long", src); -- 2.11.0