# HG changeset patch # User carl # Date 1154577965 25200 # Node ID f9917ce924a32c3b2f93cdc07576229237f5b748 # Parent b8ce1b31237d0e41c2edf4f30aa69da8d3d8b508 all dns lookups fully qualified, my_read() bug fix diff -r b8ce1b31237d -r f9917ce924a3 ChangeLog --- a/ChangeLog Tue Aug 01 15:28:13 2006 -0700 +++ b/ChangeLog Wed Aug 02 21:06:05 2006 -0700 @@ -1,5 +1,10 @@ $Id$ +5.20 2006-08-02 + Fully qualify all dns lookups. Fix my_read() bug. Try to convert + names that might be ip addresses via inet_aton before doing dns + lookups. + 5.19 2006-08-01 Bug fix - add trailing dot to uribl dns lookups to make them fully qualified. Check host names with only two components, since diff -r b8ce1b31237d -r f9917ce924a3 NEWS --- a/NEWS Tue Aug 01 15:28:13 2006 -0700 +++ b/NEWS Wed Aug 02 21:06:05 2006 -0700 @@ -1,5 +1,6 @@ $Id$ +5.20 2006-08-02 fully qualify all dns lookups; fix my_read() bug 5.19 2006-08-01 uribl dnsl lookups fully qualified; allow two component host names; rpm properly creates user 5.18 2006-04-27 sendmail no longer guarantees <> wrapper on envelopes, don't ask uribls about rfc1918 space either 5.17 2006-03-25 never ask dns blacklists about rfc1918 address space diff -r b8ce1b31237d -r f9917ce924a3 configure.in --- a/configure.in Tue Aug 01 15:28:13 2006 -0700 +++ b/configure.in Wed Aug 02 21:06:05 2006 -0700 @@ -1,7 +1,7 @@ AC_INIT(configure.in) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(dnsbl,5.19) +AM_INIT_AUTOMAKE(dnsbl,5.20) AC_PATH_PROGS(BASH, bash) AC_LANG_CPLUSPLUS diff -r b8ce1b31237d -r f9917ce924a3 src/dnsbl.cpp --- a/src/dnsbl.cpp Tue Aug 01 15:28:13 2006 -0700 +++ b/src/dnsbl.cpp Wed Aug 02 21:06:05 2006 -0700 @@ -346,7 +346,7 @@ int mlfiPriv::my_read(char *buf, int len) { if (err) return 0; int rs = 0; - while (len > 1) { + while (len) { int ws = read(fd, buf, len); if (ws > 0) { rs += ws; @@ -504,7 +504,21 @@ // milter thread is talking over its own socket to a separate resolver // process, which does the actual dns resolution. if (priv.err) return 0; // cannot ask more questions on this socket. - priv.my_write(question, strlen(question)+1); // write the question including the null terminator + if (maybe_ip) { + // might be a bare ip address, try this first to avoid dns lookups that may not be needed + in_addr ip; + if (inet_aton(question, &ip)) { + return (int)ip.s_addr; + } + } + int n = strlen(question); + if (question[n-1] == '.') { + priv.my_write(question, n+1); // write the question including the null terminator + } + else { + priv.my_write(question, n); // write the question + priv.my_write(".", 2); // and the fully qualified . terminator and null string terminator + } glommer glom; char *buf = (char *)&glom; priv.my_read(buf, sizeof(glom.length)); @@ -586,13 +600,6 @@ } } } - if (maybe_ip && !ret_address) { - // might be a bare ip address - in_addr ip; - if (inet_aton(question, &ip)) { - ret_address = ip.s_addr; - } - } pthread_mutex_unlock(&resolve_mutex); return ret_address; #else @@ -658,7 +665,7 @@ //////////////////////////////////////////////// -// lookup the domain name part of a hostname on two lists +// lookup the domain name part of a hostname on the uribl // // if we find part of the hostname on the uribl, return // true and point found to the part of the hostname that we found.