summaryrefslogtreecommitdiff
path: root/usr.bin/ssh/ssh.c
diff options
context:
space:
mode:
authorDamien Miller <djm@cvs.openbsd.org>2005-06-17 22:53:48 +0000
committerDamien Miller <djm@cvs.openbsd.org>2005-06-17 22:53:48 +0000
commit62422f756a398f490310170a6e3e3b454216f45c (patch)
treec1f0f9107368090b66d377de895ef92588bab3b9 /usr.bin/ssh/ssh.c
parentaa63bd8662fe09c801819e31bcb985a531c0d138 (diff)
Fix ControlPath's %p expanding to "0" for a default port,
spotted dwmw2 AT infradead.org; ok markus@
Diffstat (limited to 'usr.bin/ssh/ssh.c')
-rw-r--r--usr.bin/ssh/ssh.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/usr.bin/ssh/ssh.c b/usr.bin/ssh/ssh.c
index 4c34123f2de..813406f8e71 100644
--- a/usr.bin/ssh/ssh.c
+++ b/usr.bin/ssh/ssh.c
@@ -40,7 +40,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: ssh.c,v 1.243 2005/06/16 03:38:36 djm Exp $");
+RCSID("$OpenBSD: ssh.c,v 1.244 2005/06/17 22:53:46 djm Exp $");
#include <openssl/evp.h>
#include <openssl/err.h>
@@ -185,6 +185,7 @@ main(int ac, char **av)
int dummy;
extern int optind, optreset;
extern char *optarg;
+ struct servent *sp;
Forward fwd;
/*
@@ -616,6 +617,12 @@ again:
if (options.control_path != NULL)
control_client(options.control_path);
+ /* Get default port if port has not been set. */
+ if (options.port == 0) {
+ sp = getservbyname(SSH_SERVICE_NAME, "tcp");
+ options.port = sp ? ntohs(sp->s_port) : SSH_DEFAULT_PORT;
+ }
+
/* Open a connection to the remote host. */
if (ssh_connect(host, &hostaddr, options.port,
options.address_family, options.connection_attempts,