changeset 272:a99b6c1f5f67

Code cleanup, increase minimum hostname length for uribl checking
author Carl Byington <carl@five-ten-sg.com>
date Mon, 09 Sep 2013 19:30:21 -0700
parents 93d1337fd5bc
children c72e94a25a77
files ChangeLog NEWS configure.in dnsbl.spec.in src/context.cpp src/context.h src/dnsbl.cpp src/scanner.cpp
diffstat 8 files changed, 16 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon Sep 09 15:20:38 2013 -0700
+++ b/ChangeLog	Mon Sep 09 19:30:21 2013 -0700
@@ -1,3 +1,6 @@
+6.36 2013-09-09
+    Code cleanup, increase minimum hostname length for uribl checking.
+
 6.35 2013-09-09
     Use mozilla prefix list for tld checking.
     Enable surbl/uribl/dbl rhs lists.
--- a/NEWS	Mon Sep 09 15:20:38 2013 -0700
+++ b/NEWS	Mon Sep 09 19:30:21 2013 -0700
@@ -1,3 +1,4 @@
+6.36 2013-09-09 Code cleanup, increase minimum hostname length for uribl checking.
 6.35 2013-09-09 Use mozilla prefix list for tld checking. Enable surbl/uribl/dbl rhs lists.
 6.34 2013-05-22 Add require_rdns checking.
 6.33 2012-07-21 Fix unauthenticated rate limit bug for empty mail from. Move unauthenticated rate limit checks after spam filtering.
--- a/configure.in	Mon Sep 09 15:20:38 2013 -0700
+++ b/configure.in	Mon Sep 09 19:30:21 2013 -0700
@@ -1,6 +1,6 @@
 
 AC_PREREQ(2.59)
-AC_INIT(dnsbl,6.35,carl@five-ten-sg.com)
+AC_INIT(dnsbl,6.36,carl@five-ten-sg.com)
 AC_CONFIG_SRCDIR([config.h.in])
 AC_CONFIG_HEADER([config.h])
 
--- a/dnsbl.spec.in	Mon Sep 09 15:20:38 2013 -0700
+++ b/dnsbl.spec.in	Mon Sep 09 19:30:21 2013 -0700
@@ -103,6 +103,9 @@
 
 
 %changelog
+* Mon Sep 09 2013 Carl Byington <carl@five-ten-sg.com> - 6.36-1
+- Code cleanup, increase minimum hostname length for uribl checking.
+
 * Mon Sep 09 2013 Carl Byington <carl@five-ten-sg.com> - 6.35-1
 - Use mozilla prefix list for tld checking. Enable surbl/uribl/dbl
   rhs lists.
--- a/src/context.cpp	Mon Sep 09 15:20:38 2013 -0700
+++ b/src/context.cpp	Mon Sep 09 19:30:21 2013 -0700
@@ -918,14 +918,6 @@
 }
 
 
-void CONTEXT::add_tld(const char *tld) {
-    int n = strlen(tld);
-         if ((n > 1) && (tld[0] == '*') && (tld[1] == '.')) content_tldwilds.insert(tld+1);
-    else if ((n > 0) && (tld[0] == '!'))                    content_tldnots.insert(tld+1);
-    else                                                    content_tlds.insert(tld);
-}
-
-
 CONTEXTP CONTEXT::find_context(const char *from) {
     context_map::iterator i = env_from_context.find(from);
     if (i != env_from_context.end()) return (*i).second;        // found user@domain key
@@ -1435,9 +1427,7 @@
                     have = tok.next();
                     if (!have) break;
                     if (have == token_rbrace) break;  // done
-                    char buf[200];
-                    snprintf(buf, sizeof(buf), "!%s", have);
-                    me.add_tld(register_string(buf));           // leading !
+                    me.add_tldnot(have);
                 }
                 else if (have == token_asterisk) {
                     have = tok.next();
@@ -1447,9 +1437,7 @@
                         have = tok.next();
                         if (!have) break;
                         if (have == token_rbrace) break;  // done
-                        char buf[200];
-                        snprintf(buf, sizeof(buf), "*.%s", have);
-                        me.add_tld(register_string(buf));           // leading *.
+                        me.add_tldwild(have);
                     }
                 }
                 else me.add_tld(have);
--- a/src/context.h	Mon Sep 09 15:20:38 2013 -0700
+++ b/src/context.h	Mon Sep 09 19:30:21 2013 -0700
@@ -228,7 +228,9 @@
     void        set_uribl_suffix(const char *suffix)        {uribl_suffix      = suffix;      };
     void        set_uribl_message(const char *message)      {uribl_message     = message;     };
     void        add_ignore(const char *host)                {content_host_ignore.insert(host);};
-    void        add_tld(const char *tld);
+    void        add_tld(const char *tld)                    {content_tlds.insert(tld);        };
+    void        add_tldwild(const char *tld)                {content_tldwilds.insert(tld);    };
+    void        add_tldnot(const char *tld)                 {content_tldnots.insert(tld);     };
 
     void        set_host_limit(int limit)                   {host_limit         = limit;  };
     void        set_host_message(const char *message)       {host_limit_message = message;};
--- a/src/dnsbl.cpp	Mon Sep 09 15:20:38 2013 -0700
+++ b/src/dnsbl.cpp	Mon Sep 09 19:30:21 2013 -0700
@@ -397,11 +397,6 @@
 //
 bool uriblookup(mlfiPriv &priv, string_set &hosts, const char *hostname, const char *&found) ;
 bool uriblookup(mlfiPriv &priv, string_set &hosts, const char *hostname, const char *&found) {
-    if (debug_syslog > 4) {
-        char tmp[maxlen];
-        snprintf(tmp, sizeof(tmp), "looking for %s on %s", hostname, priv.uribl_suffix);
-        my_syslog(tmp);
-    }
     char buf[maxlen];
     snprintf(buf, sizeof(buf), "%s.%s.", hostname, priv.uribl_suffix);
     uint32_t ip = ntohl(dns_interface(priv, buf, false, NULL));
--- a/src/scanner.cpp	Mon Sep 09 15:20:38 2013 -0700
+++ b/src/scanner.cpp	Mon Sep 09 19:30:21 2013 -0700
@@ -1257,8 +1257,9 @@
         const char *p1 = strchr((const char *)pending, '.');
         const char *p2 = strrchr((const char *)pending, '.');
         const char *p3 = strstr((const char *)pending, "..");
-        if (p1 && (p1 != (char*)pending) & !p3) {
-            // have a period, so at least two components, and no empty components
+        size_t n = strlen((const char *)pending);
+        if (p1 && (p1 != (char*)pending) && !p3 && (n > 6)) {
+            // have a period, so at least two components, and no empty components, and longer than 6 chars
             in_addr ip;
             if (inet_aton((const char*)pending, &ip)) {
                 // have an ip address if at least two periods