# HG changeset patch # User Carl Byington # Date 1493223635 25200 # Node ID 91f2a127ec6982f613ace08a9126d7cadde59509 # Parent ea4f86e2db420a08afd53f6b9c680f71c4d56069 spf code now handles mx,exists,ptr tags, multiple A records, %{i} macro diff -r ea4f86e2db42 -r 91f2a127ec69 src/context.cpp --- a/src/context.cpp Tue Apr 25 21:57:42 2017 -0700 +++ b/src/context.cpp Wed Apr 26 09:20:35 2017 -0700 @@ -1213,6 +1213,10 @@ size_t c = a[0]; for (size_t i=1; i<=c; i++) { uint32_t ipy = ntohl(a[i]); + char adr[sizeof "255.255.255.255 "]; //!! + adr[0] = '\0'; //!! + inet_ntop(AF_INET, (const u_char *)&(a[i]), adr, sizeof(adr)); //!! + log(priv->queueid, "found mx a %s", adr); //!! if (ipy == ip) { log(priv->queueid, "match mx:%s", name); return true; diff -r ea4f86e2db42 -r 91f2a127ec69 src/dnsbl.cpp --- a/src/dnsbl.cpp Tue Apr 25 21:57:42 2017 -0700 +++ b/src/dnsbl.cpp Wed Apr 26 09:20:35 2017 -0700 @@ -306,7 +306,9 @@ // IP address 0 is returned in case of errors. // uint32_t dns_interface(mlfiPriv &priv, const char *question, int qtype, bool maybe_ip, ns_map *nameservers, char *my_answer, size_t my_size) { - if (my_answer) my_answer[0] = '\0'; // return null string if there are no txt answers + // return null string if there are no txt answers + // return zero count if there are no a answers + if (my_answer && my_size) memset(my_answer, 0, my_size); // tell sendmail we are still working #if _FFR_SMFI_PROGRESS @@ -438,15 +440,18 @@ //size_t rdlen = ns_rr_rdlen(rr); //const uint16_t pri = ns_get16(rdata); const unsigned char *rdata = ns_rr_rdata(rr); - int len = dn_expand(glom.answer, glom.answer+glom.length, rdata + 2, exchange, sizeof(exchange)); - if ((len > 0) && (my_size > (uint32_t)len+2)) { + int len = dn_expand(ns_msg_base(handle), ns_msg_base(handle) + ns_msg_size(handle), rdata + NS_INT16SZ, exchange, sizeof(exchange)); + if (len > 0) { // no error + len = strlen(exchange) + 1; + if (my_size >= (uint32_t)len+1) { strcpy(my_answer, exchange); - my_answer += len + 1; - my_size -= len + 1; + my_answer += len; + my_size -= len; c++; } } } + } *my_answer = '\0'; // final trailing null ret_address = htonl(c); }