From: florian Date: Fri, 18 Apr 2014 17:00:07 +0000 (+0000) Subject: sync to traceroute6: use getnameinfo for destination ip X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=0919a36e689e51db3a9da172c10138969c9a19af;p=openbsd sync to traceroute6: use getnameinfo for destination ip OK benno@ --- diff --git a/usr.sbin/traceroute/traceroute.c b/usr.sbin/traceroute/traceroute.c index 650059ea6cb..6bb761b4e00 100644 --- a/usr.sbin/traceroute/traceroute.c +++ b/usr.sbin/traceroute/traceroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: traceroute.c,v 1.107 2014/04/18 16:58:02 florian Exp $ */ +/* $OpenBSD: traceroute.c,v 1.108 2014/04/18 17:00:07 florian Exp $ */ /* $NetBSD: traceroute.c,v 1.10 1995/05/21 15:50:45 mycroft Exp $ */ /*- @@ -647,8 +647,10 @@ main(int argc, char *argv[]) err(1, "getsockname"); srcport = ntohs(from.sin_port); - fprintf(stderr, "traceroute to %s (%s)", hostname, - inet_ntoa(to.sin_addr)); + if (getnameinfo((struct sockaddr *)&to, to.sin_len, hbuf, + sizeof(hbuf), NULL, 0, NI_NUMERICHOST)) + strlcpy(hbuf, "(invalid)", sizeof(hbuf)); + fprintf(stderr, "%s to %s (%s)", __progname, hostname, hbuf); if (source) fprintf(stderr, " from %s", source); fprintf(stderr, ", %u hops max, %d byte packets\n", max_ttl, datalen);