From 2c69f144a8181649ea1cc44669bb2348ba69fd07 Mon Sep 17 00:00:00 2001 From: gilles Date: Thu, 11 Jan 2018 19:20:41 +0000 Subject: [PATCH] fix parsing of long TXT records, this prevents 'smtpctl spf walk' from producing bogus entries with some SPF records. ok ajacoutot@ --- usr.sbin/smtpd/spfwalk.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/usr.sbin/smtpd/spfwalk.c b/usr.sbin/smtpd/spfwalk.c index 833841adad0..64de139d37d 100644 --- a/usr.sbin/smtpd/spfwalk.c +++ b/usr.sbin/smtpd/spfwalk.c @@ -145,11 +145,9 @@ dispatch_txt(struct dns_rr *rr) char *in = buf; char *argv[512]; char **ap = argv; - + char *end; + print_dname(rr->rr.other.rdata, buf, sizeof(buf)); - buf[strlen(buf) - 1] = '\0'; - if (buf[strlen(buf) - 1] == '.') - buf[strlen(buf) - 1] = '\0'; if (strncasecmp("v=spf1 ", buf, 7)) return; @@ -157,6 +155,10 @@ dispatch_txt(struct dns_rr *rr) if (strcasecmp(*ap, "v=spf1") == 0) continue; + end = *ap + strlen(*ap)-1; + if (*end == '.') + *end = '\0'; + if (strncasecmp("ip4:", *ap, 4) == 0) { if (ip_v4 == 1 || ip_both == 1) printf("%s\n", *(ap) + 4); -- 2.20.1