only process records of the expected type.
authoreric <eric@openbsd.org>
Fri, 23 Aug 2019 15:39:11 +0000 (15:39 +0000)
committereric <eric@openbsd.org>
Fri, 23 Aug 2019 15:39:11 +0000 (15:39 +0000)
fix an issue where CNAME records generate bogus results.

ok gilles@

usr.sbin/smtpd/spfwalk.c

index 22b0579..40d4888 100644 (file)
@@ -229,6 +229,9 @@ dispatch_mx(struct dns_rr *rr)
 {
        char buf[512];
 
+       if (rr->rr_type != T_MX)
+               return;
+
        print_dname(rr->rr.mx.exchange, buf, sizeof(buf));
        buf[strlen(buf) - 1] = '\0';
        if (buf[strlen(buf) - 1] == '.')
@@ -243,6 +246,9 @@ dispatch_a(struct dns_rr *rr)
        char buffer[512];
        const char *ptr;
 
+       if (rr->rr_type != T_A)
+               return;
+
        if ((ptr = inet_ntop(AF_INET, &rr->rr.in_a.addr,
            buffer, sizeof buffer)))
                printf("%s\n", ptr);
@@ -254,6 +260,9 @@ dispatch_aaaa(struct dns_rr *rr)
        char buffer[512];
        const char *ptr;
 
+       if (rr->rr_type != T_AAAA)
+               return;
+
        if ((ptr = inet_ntop(AF_INET6, &rr->rr.in_aaaa.addr6,
            buffer, sizeof buffer)))
                printf("%s\n", ptr);