diff options
author | Damien Miller <djm@cvs.openbsd.org> | 2006-07-10 12:03:21 +0000 |
---|---|---|
committer | Damien Miller <djm@cvs.openbsd.org> | 2006-07-10 12:03:21 +0000 |
commit | 519fda1846baebc76b0375211fb4d8f59cb505d7 (patch) | |
tree | 437ddf8e8810800c25c487fe8918c2a7d5b7977e /usr.bin | |
parent | 7ffdb2935f0bd10a27a95b511260cb8d3c7a3b6e (diff) |
duplicate argv at the start of main() because it gets modified later;
pointed out by deraadt@ ok markus@
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/ssh/scp.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/usr.bin/ssh/scp.c b/usr.bin/ssh/scp.c index 60cae3f5ab4..faa756ee182 100644 --- a/usr.bin/ssh/scp.c +++ b/usr.bin/ssh/scp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scp.c,v 1.144 2006/07/09 15:15:10 stevesk Exp $ */ +/* $OpenBSD: scp.c,v 1.145 2006/07/10 12:03:20 djm Exp $ */ /* * scp - secure remote copy. This is basically patched BSD rcp which * uses ssh to do the data transfer (instead of using rcmd). @@ -268,15 +268,21 @@ void usage(void); int main(int argc, char **argv) { - int ch, fflag, tflag, status; + int ch, fflag, tflag, status, n; double speed; - char *targ, *endp; + char *targ, *endp, **newargv; extern char *optarg; extern int optind; /* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */ sanitise_stdfd(); + /* Copy argv, because we modify it */ + newargv = xcalloc(MAX(argc + 1, 1), sizeof(*newargv)); + for (n = 0; n < argc; n++) + newargv[n] = xstrdup(argv[n]); + argv = newargv; + memset(&args, '\0', sizeof(args)); args.list = NULL; addargs(&args, "%s", ssh_program); |