summaryrefslogtreecommitdiff
path: root/sftp.c
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@zip.com.au>2010-01-08 18:53:43 +1100
committerDarren Tucker <dtucker@zip.com.au>2010-01-08 18:53:43 +1100
commitb8c884a0ba4050e4267be786414127c0f09d5544 (patch)
tree18b20493bb52430d446f913e608968eb00dd49d3 /sftp.c
parent57e0d01260d3c1c7bf9366eed58c54a96eedbc81 (diff)
- guenther@cvs.openbsd.org 2009/12/20 07:28:36
[ssh.c sftp.c scp.c] When passing user-controlled options with arguments to other programs, pass the option and option argument as separate argv entries and not smashed into one (e.g., as -l foo and not -lfoo). Also, always pass a "--" argument to stop option parsing, so that a positional argument that starts with a '-' isn't treated as an option. This fixes some error cases as well as the handling of hostnames and filenames that start with a '-'. Based on a diff by halex@ ok halex@ djm@ deraadt@
Diffstat (limited to 'sftp.c')
-rw-r--r--sftp.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/sftp.c b/sftp.c
index 1aa37423c..d8728cc25 100644
--- a/sftp.c
+++ b/sftp.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sftp.c,v 1.114 2009/12/06 23:53:54 dtucker Exp $ */ 1/* $OpenBSD: sftp.c,v 1.115 2009/12/20 07:28:36 guenther Exp $ */
2/* 2/*
3 * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org> 3 * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org>
4 * 4 *
@@ -1809,7 +1809,8 @@ main(int argc, char **argv)
1809 fprintf(stderr, "Missing username\n"); 1809 fprintf(stderr, "Missing username\n");
1810 usage(); 1810 usage();
1811 } 1811 }
1812 addargs(&args, "-l%s", userhost); 1812 addargs(&args, "-l");
1813 addargs(&args, "%s", userhost);
1813 } 1814 }
1814 1815
1815 if ((cp = colon(host)) != NULL) { 1816 if ((cp = colon(host)) != NULL) {
@@ -1829,6 +1830,7 @@ main(int argc, char **argv)
1829 if (sftp_server == NULL || strchr(sftp_server, '/') == NULL) 1830 if (sftp_server == NULL || strchr(sftp_server, '/') == NULL)
1830 addargs(&args, "-s"); 1831 addargs(&args, "-s");
1831 1832
1833 addargs(&args, "--");
1832 addargs(&args, "%s", host); 1834 addargs(&args, "%s", host);
1833 addargs(&args, "%s", (sftp_server != NULL ? 1835 addargs(&args, "%s", (sftp_server != NULL ?
1834 sftp_server : "sftp")); 1836 sftp_server : "sftp"));