]> git.ipfire.org Git - thirdparty/mtr.git/commitdiff
Need to error check getnameinfo(). 113/head
authorAntonio Querubin <tony@lavanauts.org>
Tue, 3 May 2016 02:17:14 +0000 (16:17 -1000)
committerAntonio Querubin <tony@lavanauts.org>
Tue, 3 May 2016 02:17:14 +0000 (16:17 -1000)
dns.c

diff --git a/dns.c b/dns.c
index c5f6f17df4ee4785f029070294577cc805658a14..a5ba0dd49b8397e8bb5909be34811149ae870f9c 100644 (file)
--- 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);
       }
     }