]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
Prevent wildcards in source specs from matching . or ..
authorSimon Tatham <anakin@pobox.com>
Thu, 30 Nov 2000 21:35:28 +0000 (21:35 +0000)
committerSimon Tatham <anakin@pobox.com>
Thu, 30 Nov 2000 21:35:28 +0000 (21:35 +0000)
[originally from svn r813]

scp.c

diff --git a/scp.c b/scp.c
index 3f85006c0d645bff9457ca9562d3b384085c18bb..a4c03038aad1eaf63d16081c469d172e7dbfe6bc 100644 (file)
--- 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);