correctly handle "+a:..." entries
authoreric <eric@openbsd.org>
Wed, 3 Oct 2018 11:43:57 +0000 (11:43 +0000)
committereric <eric@openbsd.org>
Wed, 3 Oct 2018 11:43:57 +0000 (11:43 +0000)
from gilles@

ok otto@ gilles@

usr.sbin/smtpd/spfwalk.c

index cc9ed09..c4ce2e3 100644 (file)
@@ -170,6 +170,12 @@ dispatch_txt(struct dns_rr *rr)
                if (dict_set(&seen, *ap, &seen))
                        continue;
 
+               if (**ap == '-' || **ap == '~')
+                       continue;
+
+               if (**ap == '+' || **ap == '?')
+                       (*ap)++;
+
                if (strncasecmp("ip4:", *ap, 4) == 0) {
                        if ((ip_v4 == 1 || ip_both == 1) &&
                            inet_net_pton(AF_INET, *(ap) + 4,
@@ -184,20 +190,6 @@ dispatch_txt(struct dns_rr *rr)
                                printf("%s\n", *(ap) + 4);
                        continue;
                }
-               if (strncasecmp("+ip4:", *ap, 5) == 0) {
-                       if ((ip_v4 == 1 || ip_both == 1) &&
-                           inet_net_pton(AF_INET, *(ap) + 5,
-                           &ina, sizeof(ina)) != -1)
-                               printf("%s\n", *(ap) + 5);
-                       continue;
-               }
-               if (strncasecmp("+ip6:", *ap, 5) == 0) {
-                       if ((ip_v6 == 1 || ip_both == 1) &&
-                           inet_net_pton(AF_INET6, *(ap) + 5,
-                           &ina, sizeof(ina)) != -1)
-                               printf("%s\n", *(ap) + 5);
-                       continue;
-               }
                if (strncasecmp("a:", *ap, 2) == 0) {
                        lookup_record(T_A, *(ap) + 2, dispatch_a);
                        continue;