changeset 244:ef97c7cd4a6e stable-6-0-27

const correctness fixes from new gcc, libresolv.a moved to glibc-static on newer distributions
author Carl Byington <carl@five-ten-sg.com>
date Mon, 15 Aug 2011 21:08:11 -0700
parents b4bcc42c30ef
children c7ccb14f91b4
files ChangeLog NEWS configure.in dnsbl.spec.in src/context.cpp src/dnsbl.cpp src/scanner.cpp
diffstat 7 files changed, 47 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri Nov 19 13:04:47 2010 -0800
+++ b/ChangeLog	Mon Aug 15 21:08:11 2011 -0700
@@ -1,4 +1,7 @@
-6.26 2009-11-19
+6.27 2011-08-15
+    const correctness fixes from new gcc
+
+6.26 2010-11-19
     64 bit fixes for libresolv.a
 
 6.25 2009-09-29
--- a/NEWS	Fri Nov 19 13:04:47 2010 -0800
+++ b/NEWS	Mon Aug 15 21:08:11 2011 -0700
@@ -1,4 +1,5 @@
-6.26 2009-11-19 64 bit fixes for libresolv.a
+6.27 2011-08-15 const correctness fixes from new gcc
+6.26 2010-11-19 64 bit fixes for libresolv.a
 6.25 2009-09-29 Add surbl checks on the smtp helo value, client reverse dns name, and mail from domain name.
 6.24 2009-06-09 Add SRS decoding to envelope addresses.
 6.23 2009-05-25 Add whitelisting by regex expression filtering.
--- a/configure.in	Fri Nov 19 13:04:47 2010 -0800
+++ b/configure.in	Mon Aug 15 21:08:11 2011 -0700
@@ -1,6 +1,6 @@
 
 AC_PREREQ(2.59)
-AC_INIT(dnsbl,6.26,carl@five-ten-sg.com)
+AC_INIT(dnsbl,6.27,carl@five-ten-sg.com)
 AC_CONFIG_SRCDIR([config.h.in])
 AC_CONFIG_HEADER([config.h])
 
--- a/dnsbl.spec.in	Fri Nov 19 13:04:47 2010 -0800
+++ b/dnsbl.spec.in	Mon Aug 15 21:08:11 2011 -0700
@@ -16,6 +16,13 @@
 Requires(post,preun):   /sbin/chkconfig
 Requires(post,preun):   /sbin/service
 BuildRequires:          sendmail-devel >= 8.12.1
+BuildRequires:          glibc-devel
+%if 0%{?fedora} >= 14
+BuildRequires:          glibc-static
+%endif
+%if 0%{?el6}
+BuildRequires:          glibc-static
+%endif
 Requires:               sendmail >= 8.12.1
 Requires:               sendmail-cf
 Requires:               spamassassin
@@ -96,6 +103,9 @@
 
 
 %changelog
+* Mon Aug 15 2011 Carl Byington <carl@five-ten-sg.com> - 6.27-1
+- const correctness fixes from new gcc
+
 * Fri Nov 19 2010 Carl Byington <carl@five-ten-sg.com> - 6.26-1
 - 64bit fixes for libresolv.a
 
--- a/src/context.cpp	Fri Nov 19 13:04:47 2010 -0800
+++ b/src/context.cpp	Mon Aug 15 21:08:11 2011 -0700
@@ -853,16 +853,20 @@
     string_map::iterator i = env_from.find(from);
     if (i != env_from.end()) rc = (*i).second;  // found user@domain key
     else {
-        char *x = strchr(from, '@');
+        const char *x = strchr(from, '@');
         if (x) {
+            char buf[200];
             x++;
             i = env_from.find(x);
+            size_t n = x - from;    // length of user name plus @
             if (i != env_from.end()) rc = (*i).second;  // found domain key
-            else {
-                char y = *x;
-                *x = '\0';
-                i = env_from.find(from);
-                *x = y;
+            else if (n < sizeof(buf)) {
+                // we only test reasonably short user names, since we need
+                // to copy them to a buffer to avoid a dup/free cycle on every
+                // test here.
+                strncpy(buf, from, n);
+                buf[n] = '\0';
+                i = env_from.find(buf);
                 if (i != env_from.end()) rc = (*i).second;  // found user@ key
             }
         }
@@ -879,17 +883,23 @@
 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
-    char *x = strchr(from, '@');
+    const char *x = strchr(from, '@');
     if (x) {
+        char buf[200];
         x++;
         i = env_from_context.find(x);
+        size_t n = x - from;    // length of user name plus @
         if (i != env_from_context.end()) return (*i).second;    // found domain key
-        char y = *x;
-        *x = '\0';
-        i = env_from_context.find(from);
-        *x = y;
+        else if (n < sizeof(buf)) {
+            // we only test reasonably short user names, since we need
+            // to copy them to a buffer to avoid a dup/free cycle on every
+            // test here.
+            strncpy(buf, from, n);
+            buf[n] = '\0';
+            i = env_from_context.find(buf);
         if (i != env_from_context.end()) return (*i).second;    // found user@ key
     }
+    }
     return this;
 }
 
--- a/src/dnsbl.cpp	Fri Nov 19 13:04:47 2010 -0800
+++ b/src/dnsbl.cpp	Mon Aug 15 21:08:11 2011 -0700
@@ -673,7 +673,7 @@
                 if (client_name && !helo_uribl) {
                     client_uribl = check_uribl(*this, hosts_uribl, client_name, host_uribl);
                     if (mailaddr && !client_uribl) {
-                        char *f = strchr(mailaddr, '@');
+                        const char *f = strchr(mailaddr, '@');
                         if (f) from_uribl = check_uribl(*this, hosts_uribl, f+1, host_uribl);
                     }
                 }
@@ -1553,7 +1553,7 @@
     bool stress  = false;
     bool setconn = false;
     bool setreso = false;
-    const char *email = NULL;
+    char *email = NULL;
     int c;
     const char *args = "b:r:p:t:e:d:chs";
     extern char *optarg;
--- a/src/scanner.cpp	Fri Nov 19 13:04:47 2010 -0800
+++ b/src/scanner.cpp	Mon Aug 15 21:08:11 2011 -0700
@@ -140,7 +140,7 @@
     void push(u_char *buf, int len);
     void pusher();
     void validhost();
-    void error(char *err);
+    void error(const char *err);
 };
 
 
@@ -1235,7 +1235,7 @@
     memory = memory_;
 }
 
-void fsa::error(char *err) {
+void fsa::error(const char *err) {
     count = 0;
     st    = init;
     if (err) memory->syslog(err);
@@ -1253,9 +1253,9 @@
     if (!count) return; // empty string
     if (!strchr((const char *)pending, '@')) {
         // not an email address or message id
-        char *p1 = strchr((const char *)pending, '.');
-        char *p2 = strrchr((const char *)pending, '.');
-        char *p3 = strstr((const char *)pending, "..");
+        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
             in_addr ip;
@@ -1354,7 +1354,7 @@
                     pending[--count] = '\0';  // null terminate host name by overwriting the terminator
                     // must start with protocol
                     if (strncasecmp((const char *)pending, "http", 4) == 0) {
-                        char *p = strrchr((const char *)pending, '/');
+                        const char *p = strrchr((const char *)pending, '/');
                         if (p) {
                             count = strlen(p+1);
                             memmove(pending, p+1, count+1);