Mercurial > dnsbl
diff src/dnsbl.cpp @ 409:e018ed19a1cc
require 3 dots in bare ip addresses
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Sun, 16 Apr 2017 09:06:52 -0700 |
parents | 9096d2676c13 |
children | 6b03435868cb |
line wrap: on
line diff
--- a/src/dnsbl.cpp Thu Mar 30 10:31:23 2017 -0700 +++ b/src/dnsbl.cpp Sun Apr 16 09:06:52 2017 -0700 @@ -316,9 +316,15 @@ // process, which does the actual dns resolution. if (priv.err) return 0; // cannot ask more questions on this socket. if (maybe_ip && (qtype == ns_t_a)) { - // might be a bare ip address, try this first to avoid dns lookups that may not be needed + int c = 0; + const char q = question; + while (*q) { + if (*q == '.') c++; + q++; + } + // might be a bare IPv4 address, try this first to avoid dns lookups that may not be needed in_addr ip; - if (inet_aton(question, &ip)) { + if ((c == 3) && inet_aton(question, &ip)) { return ip.s_addr; } }