1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-04-21 04:55:02 -05:00

Avoid recursing into . and .. when in -r mode

[originally from svn r332]
This commit is contained in:
Simon Tatham 1999-11-30 11:53:42 +00:00
parent d5123675aa
commit cc98ca9aea

19
scp.c
View File

@ -277,10 +277,25 @@ static void source(char *src)
} }
if ((attr & FILE_ATTRIBUTE_DIRECTORY) != 0) { if ((attr & FILE_ATTRIBUTE_DIRECTORY) != 0) {
if (recursive) if (recursive) {
rsource(src); /*
* Avoid . and .. directories.
*/
char *p;
p = strrchr(src, '/');
if (!p)
p = strrchr(src, '\\');
if (!p)
p = src;
else else
p++;
if (!strcmp(p, ".") || !strcmp(p, ".."))
/* skip . and .. */;
else
rsource(src);
} else {
run_err("%s: not a regular file", src); run_err("%s: not a regular file", src);
}
return; return;
} }