From: Antonio Querubin Date: Tue, 3 May 2016 02:17:14 +0000 (-1000) Subject: Need to error check getnameinfo(). X-Git-Tag: v0.88~43^2~3^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F113%2Fhead;p=thirdparty%2Fmtr.git Need to error check getnameinfo(). --- diff --git a/dns.c b/dns.c index c5f6f17..a5ba0dd 100644 --- a/dns.c +++ b/dns.c @@ -218,13 +218,13 @@ void dns_open(void) rv = getnameinfo ((struct sockaddr *) &sa, salen, hostname, sizeof (hostname), NULL, 0, 0); + if (rv == 0) { + sprintf (result, "%s %s\n", strlongip (&host), hostname); + //printf ("resolved: %s -> %s (%d)\n", strlongip (&host), hostname, rv); + rv = write (fromdns[1], result, strlen (result)); + if (rv < 0) perror ("write DNS lookup result"); + } - sprintf (result, "%s %s\n", strlongip (&host), hostname); - - //printf ("resolved: %s -> %s (%d)\n", strlongip (&host), hostname, rv); - - rv = write (fromdns[1], result, strlen (result)); - if (rv < 0) perror ("write DNS lookup result"); exit (0); } }