summaryrefslogtreecommitdiffstats
path: root/sftp.c
diff options
context:
space:
mode:
authordtucker@openbsd.org <dtucker@openbsd.org>2019-06-07 05:47:12 +0200
committerDarren Tucker <dtucker@dtucker.net>2019-06-07 16:25:42 +0200
commit25e3bccbaa63d27b9d5e09c123f1eb28594d2bd6 (patch)
treecde574c536cb15f78f91a35a16e25cfebc17a227 /sftp.c
parentupstream: Replace calls to ssh_malloc_init() by a static init of (diff)
downloadopenssh-25e3bccbaa63d27b9d5e09c123f1eb28594d2bd6.tar.xz
openssh-25e3bccbaa63d27b9d5e09c123f1eb28594d2bd6.zip
upstream: Check for user@host when parsing sftp target. This
allows user@[1.2.3.4] to work without a path in addition to with one. bz#2999, ok djm@ OpenBSD-Commit-ID: d989217110932490ba8ce92127a9a6838878928b
Diffstat (limited to '')
-rw-r--r--sftp.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/sftp.c b/sftp.c
index 04881c83f..03c7a5c72 100644
--- a/sftp.c
+++ b/sftp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sftp.c,v 1.191 2019/06/06 05:13:13 otto Exp $ */
+/* $OpenBSD: sftp.c,v 1.192 2019/06/07 03:47:12 dtucker Exp $ */
/*
* Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org>
*
@@ -2527,12 +2527,17 @@ main(int argc, char **argv)
port = tmp;
break;
default:
+ /* Try with user, host and path. */
if (parse_user_host_path(*argv, &user, &host,
- &file1) == -1) {
- /* Treat as a plain hostname. */
- host = xstrdup(*argv);
- host = cleanhostname(host);
- }
+ &file1) == 0)
+ break;
+ /* Try with user and host. */
+ if (parse_user_host_port(*argv, &user, &host, NULL)
+ == 0)
+ break;
+ /* Treat as a plain hostname. */
+ host = xstrdup(*argv);
+ host = cleanhostname(host);
break;
}
file2 = *(argv + 1);