summaryrefslogtreecommitdiff
path: root/misc.c
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@zip.com.au>2006-07-10 23:04:19 +1000
committerDarren Tucker <dtucker@zip.com.au>2006-07-10 23:04:19 +1000
commitda3455356100dbcb5d1ff9f0556386ca5f788795 (patch)
tree013d0f5e5bca486e4e72387d94980fc81d402a50 /misc.c
parent0f07707267fd3911bcf95b48125b522f9e222c64 (diff)
- dtucker@cvs.openbsd.org 2006/07/10 12:46:51
[misc.c misc.h sshd.8 sshconnect.c] Add port identifier to known_hosts for non-default ports, based originally on a patch from Devin Nate in bz#910. For any connection using the default port or using a HostKeyAlias the format is unchanged, otherwise the host name or address is enclosed within square brackets in the same format as sshd's ListenAddress. Tested by many, ok markus@.
Diffstat (limited to 'misc.c')
-rw-r--r--misc.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/misc.c b/misc.c
index 2abb14051..a65b1fded 100644
--- a/misc.c
+++ b/misc.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: misc.c,v 1.55 2006/07/09 15:15:10 stevesk Exp $ */ 1/* $OpenBSD: misc.c,v 1.56 2006/07/10 12:46:51 dtucker Exp $ */
2/* 2/*
3 * Copyright (c) 2000 Markus Friedl. All rights reserved. 3 * Copyright (c) 2000 Markus Friedl. All rights reserved.
4 * Copyright (c) 2005,2006 Damien Miller. All rights reserved. 4 * Copyright (c) 2005,2006 Damien Miller. All rights reserved.
@@ -45,6 +45,7 @@
45#include "misc.h" 45#include "misc.h"
46#include "log.h" 46#include "log.h"
47#include "xmalloc.h" 47#include "xmalloc.h"
48#include "ssh.h"
48 49
49/* remove newline at end of string */ 50/* remove newline at end of string */
50char * 51char *
@@ -337,6 +338,23 @@ convtime(const char *s)
337} 338}
338 339
339/* 340/*
341 * Returns a standardized host+port identifier string.
342 * Caller must free returned string.
343 */
344char *
345put_host_port(const char *host, u_short port)
346{
347 char *hoststr;
348
349 if (port == 0 || port == SSH_DEFAULT_PORT)
350 return(xstrdup(host));
351 if (asprintf(&hoststr, "[%s]:%d", host, (int)port) < 0)
352 fatal("put_host_port: asprintf: %s", strerror(errno));
353 debug3("put_host_port: %s", hoststr);
354 return hoststr;
355}
356
357/*
340 * Search for next delimiter between hostnames/addresses and ports. 358 * Search for next delimiter between hostnames/addresses and ports.
341 * Argument may be modified (for termination). 359 * Argument may be modified (for termination).
342 * Returns *cp if parsing succeeds. 360 * Returns *cp if parsing succeeds.