diff options
author | Eric Faurot <eric@cvs.openbsd.org> | 2018-03-14 21:16:32 +0000 |
---|---|---|
committer | Eric Faurot <eric@cvs.openbsd.org> | 2018-03-14 21:16:32 +0000 |
commit | 8190d9ee85639d85e01af5221a7b1560eeaa3ee1 (patch) | |
tree | 1ec569027a675ee6a1f5b76578e6662edb7c3aee /usr.sbin/smtpd | |
parent | f281b218d1a23e70e39852cd821deabf1f0c9678 (diff) |
skip spf mechanisms that have been processed already.
prevent possible loops on badly configured spf records.
ok gilles@
Diffstat (limited to 'usr.sbin/smtpd')
-rw-r--r-- | usr.sbin/smtpd/spfwalk.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/usr.sbin/smtpd/spfwalk.c b/usr.sbin/smtpd/spfwalk.c index 6ba83faffd3..83a675959b5 100644 --- a/usr.sbin/smtpd/spfwalk.c +++ b/usr.sbin/smtpd/spfwalk.c @@ -15,6 +15,7 @@ */ #include <sys/socket.h> +#include <sys/tree.h> #include <arpa/inet.h> #include <arpa/nameser.h> @@ -31,7 +32,9 @@ #include <strings.h> #include <unistd.h> +#define LINE_MAX 1024 #include "smtpd-defines.h" +#include "smtpd-api.h" #include "unpack_dns.h" #include "parser.h" @@ -49,6 +52,8 @@ int ip_v4 = 0; int ip_v6 = 0; int ip_both = 1; +struct dict seen; + int spfwalk(int argc, struct parameter *argv) { @@ -74,6 +79,7 @@ spfwalk(int argc, struct parameter *argv) argv += optind; argc -= optind; + dict_init(&seen); event_init(); while ((linelen = getline(&line, &linesize, stdin)) != -1) { @@ -158,6 +164,9 @@ dispatch_txt(struct dns_rr *rr) if (*end == '.') *end = '\0'; + if (dict_set(&seen, *ap, &seen)) + continue; + if (strncasecmp("ip4:", *ap, 4) == 0) { if (ip_v4 == 1 || ip_both == 1) printf("%s\n", *(ap) + 4); |