diff src/context.cpp @ 388:2354a1944e49

start parsing spf txt records
author Carl Byington <carl@five-ten-sg.com>
date Mon, 06 Mar 2017 16:22:15 -0800
parents 7b7066a51c33
children bcef093b1ba6
line wrap: on
line diff
--- a/src/context.cpp	Mon Mar 06 15:41:14 2017 -0800
+++ b/src/context.cpp	Mon Mar 06 16:22:15 2017 -0800
@@ -1140,19 +1140,18 @@
             if (s) *s = '\0';
             in_addr ipx;
             if (inet_aton(p, &ipx)) {
-                if (s) {
-                    int mask = atoi(s+1);
+                uint32_t ipy = htonl(ipx.s_addr);
+                int mask = (s) ? atoi(s+1) : 32;
                     if ((mask >= 16) && (mask <= 32)) {
-                        int low = (1 << (32-mask)) - 1;
-                        ipx.s_addr &= low ^ 0xffffffff;
-                        if ((ip >= ipx.s_addr) && (ip <= ipx.s_addr + low)) {
+                    uint32_t low = (1 << (32-mask)) - 1;
+                    ipy &= low ^ 0xffffffff;
+                    if ((ipy <= ip) && (ip <= ipy + low)) {
                             log(priv->queueid, "match %s", p);
                             if (s) log(priv->queueid, "match /%s", s+1);
                             return true;
                         }
                     }
                 }
-            }
             if (b) *b = ' ';
             if (s) *s = '/';
             p = (b) ? b+1 : e;