# HG changeset patch # User Carl Byington # Date 1488846135 28800 # Node ID 2354a1944e4915f7cad0b7497b9c174be6a3b786 # Parent 616e46e9b8f06f8b1f615e8ebdef9780075c59d7 start parsing spf txt records diff -r 616e46e9b8f0 -r 2354a1944e49 src/context.cpp --- 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; diff -r 616e46e9b8f0 -r 2354a1944e49 src/dnsbl.cpp --- a/src/dnsbl.cpp Mon Mar 06 15:41:14 2017 -0800 +++ b/src/dnsbl.cpp Mon Mar 06 16:22:15 2017 -0800 @@ -887,11 +887,12 @@ // find the answer #ifdef NS_PACKETSZ - int res_result = res_query(question+1, ns_c_in, int8_t(question[0]), glom.answer, sizeof(glom.answer)); + int qt = int8_t(question[0]); + int res_result = res_query(question+1, ns_c_in, qt, glom.answer, sizeof(glom.answer)); //#ifdef RESOLVER_DEBUG char text[1000]; snprintf(text, sizeof(text), "process_resolver_requests() has a question %s qtype %d buf len %d result %d", - question+1, int8_t(question[0]), sizeof(glom.answer), res_result); + question+1, qt, sizeof(glom.answer), res_result); my_syslog(text); //#endif if (res_result < 0) glom.length = 0; // represent all errors as zero length answers