From abd19699de943db357726b3c456f8bed82702459 Mon Sep 17 00:00:00 2001 From: Jun-ichiro itojun Hagino Date: Sat, 8 Jun 2002 21:15:28 +0000 Subject: always use getnameinfo. (diag message only) --- usr.bin/ssh/sshconnect.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) (limited to 'usr.bin') diff --git a/usr.bin/ssh/sshconnect.c b/usr.bin/ssh/sshconnect.c index a41a84abd62..da49ee0b410 100644 --- a/usr.bin/ssh/sshconnect.c +++ b/usr.bin/ssh/sshconnect.c @@ -13,7 +13,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: sshconnect.c,v 1.120 2002/05/23 19:24:30 markus Exp $"); +RCSID("$OpenBSD: sshconnect.c,v 1.121 2002/06/08 21:15:27 itojun Exp $"); #include @@ -42,21 +42,11 @@ extern char *__progname; static const char * sockaddr_ntop(struct sockaddr *sa) { - void *addr; - static char addrbuf[INET6_ADDRSTRLEN]; + static char addrbuf[NI_MAXHOST]; - switch (sa->sa_family) { - case AF_INET: - addr = &((struct sockaddr_in *)sa)->sin_addr; - break; - case AF_INET6: - addr = &((struct sockaddr_in6 *)sa)->sin6_addr; - break; - default: - /* This case should be protected against elsewhere */ + if (getnameinfo(sa, sa->sa_len, addrbuf, sizeof(addrbuf), NULL, 0, + NI_NUMERICHOST) != 0) abort(); /* XXX abort is bad -- do something else */ - } - inet_ntop(sa->sa_family, addr, addrbuf, sizeof(addrbuf)); return addrbuf; } -- cgit v1.2.3