diff src/dnsbl.cpp @ 419:91f2a127ec69 stable-6-0-57

spf code now handles mx,exists,ptr tags, multiple A records, %{i} macro
author Carl Byington <carl@five-ten-sg.com>
date Wed, 26 Apr 2017 09:20:35 -0700
parents 16451edcb962
children 1b7a785610f5
line wrap: on
line diff
--- 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);
             }