changeset 415:16451edcb962

spf code now handles mx,exists,ptr tags, multiple A records, %{i} macro
author Carl Byington <carl@five-ten-sg.com>
date Tue, 25 Apr 2017 15:23:33 -0700
parents d5a1ed33d3ae
children 7431e948b5c3
files src/context.cpp src/dnsbl.cpp
diffstat 2 files changed, 10 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/context.cpp	Tue Apr 25 14:48:19 2017 -0700
+++ b/src/context.cpp	Tue Apr 25 15:23:33 2017 -0700
@@ -1193,7 +1193,7 @@
                 else if (strncmp(p, "exists:", 7) == 0) {
                     p += 7;
                     char buf[maxlen];
-                    uint32_t ipy = ntohl(dns_interface(*priv, p, ns_t_a, false, NULL, buf, maxlen));
+                    dns_interface(*priv, p, ns_t_a, false, NULL, buf, maxlen);
                     uint32_t *a = (uint32_t *)buf;
                     if (a[0]) {
                         log(priv->queueid, "match exists:%s", p);
@@ -1203,15 +1203,15 @@
                 else if (strncmp(p, "mx", 2) == 0) {
                     const char *name = (p[2] == ':') ? p+2 : from;
                     char buf[maxlen];
-                    uint32_t c = ntohl(dns_interface(*priv, name, ns_t_mx, false, NULL, buf, maxlen));
+                    dns_interface(*priv, name, ns_t_mx, false, NULL, buf, maxlen);
                     char *b = buf;
                     while (*b) {
                         log(priv->queueid, "found mx %s", b);
-                        char abuf[maxlen];
-                        uint32_t ipy = ntohl(dns_interface(*priv, b, ns_t_a, false, NULL, buf, maxlen));
+                        char buf[maxlen];
+                        dns_interface(*priv, b, ns_t_a, false, NULL, buf, maxlen);
                         uint32_t *a = (uint32_t *)buf;
                         size_t c = a[0];
-                        for (size_t i=1; i++; i<=c) {
+                        for (size_t i=1; i<=c; i++) {
                             ipy = ntohl(a[i]);
                             if (ipy == ip) {
                                 log(priv->queueid, "match mx:%s", name);
@@ -1227,7 +1227,7 @@
                     uint32_t ipy = ntohl(dns_interface(*priv, name, ns_t_a, false, NULL, buf, maxlen));
                     uint32_t *a = (uint32_t *)buf;
                     size_t c = a[0];
-                    for (size_t i=1; i++; i<=c) {
+                    for (size_t i=1; i<=c; i++) {
                         ipy = ntohl(a[i]);
                         if (ipy == ip) {
                             log(priv->queueid, "match a:%s", name);
--- a/src/dnsbl.cpp	Tue Apr 25 14:48:19 2017 -0700
+++ b/src/dnsbl.cpp	Tue Apr 25 15:23:33 2017 -0700
@@ -435,11 +435,11 @@
                 while (ns_parserr(&handle, ns_s_an, rrnum++, &rr) == 0) {
                     if (ns_rr_type(rr) == qtype) {
                         char exchange[NS_MAXDNAME];
-                        size_t rdlen = ns_rr_rdlen(rr);
+                        //size_t rdlen = ns_rr_rdlen(rr);
+                        //const uint16_t pri = ns_get16(rdata);
                         const unsigned char *rdata = ns_rr_rdata(rr);
-                        const uint16_t pri = ns_get16(rdata);
                         int len = dn_expand(glom.answer, glom.answer+glom.length, rdata + 2, exchange, sizeof(exchange));
-                        if ((len > 0) && (my_size > len+2)) {
+                        if ((len > 0) && (my_size > (uint32_t)len+2)) {
                             strcpy(my_answer, exchange);
                             my_answer += len + 1;
                             my_size   -= len + 1;
@@ -1733,7 +1733,7 @@
         }
 
         CONTEXT *con = NULL;
-        const char *st;
+        const char *st = token_black;
         for (context_map::iterator i=priv.env_to.begin(); i!=priv.env_to.end(); i++) {
             const char *rcpt = (*i).first;
             CONTEXT    *next = (*i).second;