summaryrefslogtreecommitdiff
path: root/readconf.c
diff options
context:
space:
mode:
authornaddy@openbsd.org <naddy@openbsd.org>2018-10-05 14:26:09 +0000
committerDamien Miller <djm@mindrot.org>2018-10-07 14:58:24 +1100
commit2581333d564d8697837729b3d07d45738eaf5a54 (patch)
treed0fba4a6a1df98cbd17e428a07321f5339d5471a /readconf.c
parente0d6501e86734c48c8c503f81e1c0926e98c5c4c (diff)
upstream: Support using service names for port numbers.
* Try to resolve a port specification with getservbyname(3) if a numeric conversion fails. * Make the "Port" option in ssh_config handle its argument as a port rather than a plain integer. ok dtucker@ deraadt@ OpenBSD-Commit-ID: e7f03633133205ab3dfbc67f9df7475fabae660d
Diffstat (limited to 'readconf.c')
-rw-r--r--readconf.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/readconf.c b/readconf.c
index d39cfa3c..43381152 100644
--- a/readconf.c
+++ b/readconf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: readconf.c,v 1.299 2018/10/03 06:38:35 djm Exp $ */
+/* $OpenBSD: readconf.c,v 1.300 2018/10/05 14:26:09 naddy Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -1158,7 +1158,20 @@ parse_command:
return 0;
case oPort:
- intptr = &options->port;
+ arg = strdelim(&s);
+ if (!arg || *arg == '\0')
+ fatal("%.200s line %d: Missing argument.",
+ filename, linenum);
+ value = a2port(arg);
+ if (value <= 0)
+ fatal("%.200s line %d: Bad port '%s'.",
+ filename, linenum, arg);
+ if (*activep && options->port == -1)
+ options->port = value;
+ break;
+
+ case oConnectionAttempts:
+ intptr = &options->connection_attempts;
parse_int:
arg = strdelim(&s);
if ((errstr = atoi_err(arg, &value)) != NULL)
@@ -1168,10 +1181,6 @@ parse_int:
*intptr = value;
break;
- case oConnectionAttempts:
- intptr = &options->connection_attempts;
- goto parse_int;
-
case oCiphers:
arg = strdelim(&s);
if (!arg || *arg == '\0')