-if (dns_lookup(dnsa, US domain, rr_type, NULL) == DNS_SUCCEED)
- for (dns_record * rr = dns_next_rr(dnsa, &dnss, RESET_ANSWERS); rr;
- rr = dns_next_rr(dnsa, &dnss, RESET_NEXT))
- if ( rr->type == rr_type
- && (rr_type != T_TXT || Ustrncmp(rr->data+1, "v=spf1", 6) == 0))
+if (dns_lookup(dnsa, US domain, rr_type, NULL) == DNS_NOMATCH)
+ {
+ SPF_dns_rr_dup(&spfrr, spf_nxdomain);
+ return spfrr;
+}
+
+for (dns_record * rr = dns_next_rr(dnsa, &dnss, RESET_ANSWERS); rr;
+ rr = dns_next_rr(dnsa, &dnss, RESET_NEXT))
+ if (rr->type == rr_type) found++;
+
+srr.num_rr = found;
+srr.rr = store_malloc(sizeof(SPF_dns_rr_data_t) * found);
+srr.herrno = h_errno,
+
+found = 0;
+for (dns_record * rr = dns_next_rr(dnsa, &dnss, RESET_ANSWERS); rr;
+ rr = dns_next_rr(dnsa, &dnss, RESET_NEXT))
+ if (rr->type == rr_type)
+ {
+ const uschar * s = rr->data;
+
+ srr.ttl = rr->ttl;
+ switch(rr_type)