summaryrefslogtreecommitdiff
path: root/ssh-keyscan.c
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2015-10-24 22:56:19 +0000
committerDamien Miller <djm@mindrot.org>2015-10-25 11:42:07 +1100
commit9ada37d36003a77902e90a3214981e417457cf13 (patch)
tree2f8aa3d1cc0daca40c066ed39208b1698a06d1d3 /ssh-keyscan.c
parent44fc7cd7dcef6c52c6b7e9ff830dfa32879bd319 (diff)
upstream commit
fix keyscan output for multiple hosts/addrs on one line when host hashing or a non standard port is in use; bz#2479 ok dtucker@ Upstream-ID: 5321dabfaeceba343da3c8a8b5754c6f4a0a307b
Diffstat (limited to 'ssh-keyscan.c')
-rw-r--r--ssh-keyscan.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/ssh-keyscan.c b/ssh-keyscan.c
index 57d88429b..7db0e10e5 100644
--- a/ssh-keyscan.c
+++ b/ssh-keyscan.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh-keyscan.c,v 1.101 2015/04/10 00:08:55 djm Exp $ */ 1/* $OpenBSD: ssh-keyscan.c,v 1.102 2015/10/24 22:56:19 djm Exp $ */
2/* 2/*
3 * Copyright 1995, 1996 by David Mazieres <dm@lcs.mit.edu>. 3 * Copyright 1995, 1996 by David Mazieres <dm@lcs.mit.edu>.
4 * 4 *
@@ -296,13 +296,10 @@ keygrab_ssh2(con *c)
296} 296}
297 297
298static void 298static void
299keyprint(con *c, struct sshkey *key) 299keyprint_one(char *host, struct sshkey *key)
300{ 300{
301 char *host = c->c_output_name ? c->c_output_name : c->c_name; 301 char *hostport;
302 char *hostport = NULL;
303 302
304 if (!key)
305 return;
306 if (hash_hosts && (host = host_hash(host, NULL, 0)) == NULL) 303 if (hash_hosts && (host = host_hash(host, NULL, 0)) == NULL)
307 fatal("host_hash failed"); 304 fatal("host_hash failed");
308 305
@@ -313,6 +310,24 @@ keyprint(con *c, struct sshkey *key)
313 free(hostport); 310 free(hostport);
314} 311}
315 312
313static void
314keyprint(con *c, struct sshkey *key)
315{
316 char *hosts = c->c_output_name ? c->c_output_name : c->c_name;
317 char *host, *ohosts;
318
319 if (key == NULL)
320 return;
321 if (!hash_hosts && ssh_port == SSH_DEFAULT_PORT) {
322 keyprint_one(hosts, key);
323 return;
324 }
325 ohosts = hosts = xstrdup(hosts);
326 while ((host = strsep(&hosts, ",")) != NULL)
327 keyprint_one(host, key);
328 free(ohosts);
329}
330
316static int 331static int
317tcpconnect(char *host) 332tcpconnect(char *host)
318{ 333{