]> git.ipfire.org Git - thirdparty/mtr.git/commitdiff
fix(dns): check resolver pipe setup failures 603/head
authorDarafei Praliaskouski <me@komzpa.net>
Thu, 7 May 2026 22:06:11 +0000 (02:06 +0400)
committerDarafei Praliaskouski <me@komzpa.net>
Fri, 8 May 2026 03:16:38 +0000 (07:16 +0400)
ui/dns.c

index 03a829ea85766ab465dd4d881ad0ea78be6ab4b1..f0551af1c37c2985a1aabc93c59967974250f019 100644 (file)
--- a/ui/dns.c
+++ b/ui/dns.c
@@ -162,6 +162,9 @@ void dns_open(
             close(i);
         }
         infp = fdopen(todns[0], "r");
+        if (!infp) {
+            error(EXIT_FAILURE, errno, "fdopen DNS lookup pipe");
+        }
 
         while (fgets(buf, sizeof(buf), infp)) {
             ip_t host;
@@ -207,9 +210,17 @@ void dns_open(
         close(todns[0]);        /* close the pipe ends we don't need. */
         close(fromdns[1]);
         fromdnsfp = fdopen(fromdns[0], "r");
+        if (fromdnsfp == NULL) {
+            error(EXIT_FAILURE, errno, "fdopen DNS result pipe");
+        }
         flags = fcntl(fromdns[0], F_GETFL, 0);
+        if (flags < 0) {
+            error(EXIT_FAILURE, errno, "fcntl DNS result pipe");
+        }
         flags |= O_NONBLOCK;
-        fcntl(fromdns[0], F_SETFL, flags);
+        if (fcntl(fromdns[0], F_SETFL, flags) < 0) {
+            error(EXIT_FAILURE, errno, "fcntl DNS result pipe");
+        }
     }
 }