From 159ac2e8cd9fb69c21916bdf5f742eccbb4f2695 Mon Sep 17 00:00:00 2001 From: Ben Lindstrom Date: Sun, 9 Jun 2002 20:14:54 +0000 Subject: [PATCH] - itojun@cvs.openbsd.org 2002/06/08 21:15:27 [sshconnect.c] always use getnameinfo. (diag message only) --- ChangeLog | 5 ++++- sshconnect.c | 18 ++++-------------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index b20405506..efe3bea9a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -22,6 +22,9 @@ [readconf.c] silently ignore deprecated options, since FallBackToRsh might be passed by remote scp commands. + - itojun@cvs.openbsd.org 2002/06/08 21:15:27 + [sshconnect.c] + always use getnameinfo. (diag message only) 20020607 - (bal) Removed --{enable/disable}-suid-ssh @@ -853,4 +856,4 @@ - (stevesk) entropy.c: typo in debug message - (djm) ssh-keygen -i needs seeded RNG; report from markus@ -$Id: ChangeLog,v 1.2195 2002/06/09 20:13:27 mouring Exp $ +$Id: ChangeLog,v 1.2196 2002/06/09 20:14:54 mouring Exp $ diff --git a/sshconnect.c b/sshconnect.c index 7af0b9a80..9444e3cf2 100644 --- a/sshconnect.c +++ b/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 @@ -46,21 +46,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; }