summaryrefslogtreecommitdiffstats
path: root/scp.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2006-07-10 22:19:53 +1000
committerDamien Miller <djm@mindrot.org>2006-07-10 22:19:53 +1000
commit3d1a9f4d5dfed0d2607b7cb36e1608255a669a17 (patch)
treeaae62c88613c8f1ffade3be2d5b8722cce03fb30 /scp.c
parenta1738e4c65108b9c549c66c3a668a04b86c1530c (diff)
- djm@cvs.openbsd.org 2006/07/10 12:03:20
[scp.c] duplicate argv at the start of main() because it gets modified later; pointed out by deraadt@ ok markus@
Diffstat (limited to 'scp.c')
-rw-r--r--scp.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/scp.c b/scp.c
index 600df161..6fe246d8 100644
--- a/scp.c
+++ b/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).
@@ -272,15 +272,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;
+
__progname = ssh_get_progname(argv[0]);
memset(&args, '\0', sizeof(args));