summaryrefslogtreecommitdiff
path: root/ssh.c
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2017-08-12 06:46:01 +0000
committerDamien Miller <djm@mindrot.org>2017-08-12 16:47:10 +1000
commit643c2ad82910691b2240551ea8b14472f60b5078 (patch)
tree638368cb3fa9497c2c7b0603a855ea8b0936be2b /ssh.c
parent0f3455356bc284d7c6f4d3c1614d31161bd5dcc2 (diff)
upstream commit
make "--" before the hostname terminate command-line option processing completely; previous behaviour would not prevent further options appearing after the hostname (ssh has a supported options after the hostname for >20 years, so that's too late to change). ok deraadt@ Upstream-ID: ef5ee50571b98ad94dcdf8282204e877ec88ad89
Diffstat (limited to 'ssh.c')
-rw-r--r--ssh.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/ssh.c b/ssh.c
index 6137fd7da..019d1d31c 100644
--- a/ssh.c
+++ b/ssh.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh.c,v 1.461 2017/05/30 18:58:37 bluhm Exp $ */ 1/* $OpenBSD: ssh.c,v 1.462 2017/08/12 06:46:01 djm Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -509,13 +509,13 @@ int
509main(int ac, char **av) 509main(int ac, char **av)
510{ 510{
511 struct ssh *ssh = NULL; 511 struct ssh *ssh = NULL;
512 int i, r, opt, exit_status, use_syslog, direct, config_test = 0; 512 int i, r, opt, exit_status, use_syslog, direct, timeout_ms;
513 int config_test = 0, opt_terminated = 0;
513 char *p, *cp, *line, *argv0, buf[PATH_MAX], *host_arg, *logfile; 514 char *p, *cp, *line, *argv0, buf[PATH_MAX], *host_arg, *logfile;
514 char thishost[NI_MAXHOST], shorthost[NI_MAXHOST], portstr[NI_MAXSERV]; 515 char thishost[NI_MAXHOST], shorthost[NI_MAXHOST], portstr[NI_MAXSERV];
515 char cname[NI_MAXHOST], uidstr[32], *conn_hash_hex; 516 char cname[NI_MAXHOST], uidstr[32], *conn_hash_hex;
516 struct stat st; 517 struct stat st;
517 struct passwd *pw; 518 struct passwd *pw;
518 int timeout_ms;
519 extern int optind, optreset; 519 extern int optind, optreset;
520 extern char *optarg; 520 extern char *optarg;
521 struct Forward fwd; 521 struct Forward fwd;
@@ -917,6 +917,9 @@ main(int ac, char **av)
917 } 917 }
918 } 918 }
919 919
920 if (optind > 1 && strcmp(av[optind - 1], "--") == 0)
921 opt_terminated = 1;
922
920 ac -= optind; 923 ac -= optind;
921 av += optind; 924 av += optind;
922 925
@@ -931,7 +934,7 @@ main(int ac, char **av)
931 host = xstrdup(++cp); 934 host = xstrdup(++cp);
932 } else 935 } else
933 host = xstrdup(*av); 936 host = xstrdup(*av);
934 if (ac > 1) { 937 if (ac > 1 && !opt_terminated) {
935 optind = optreset = 1; 938 optind = optreset = 1;
936 goto again; 939 goto again;
937 } 940 }