changeset 266:582cfb9c4031 stable-6-0-33

fix unauthenticated rate limit bug for empty mail from
author Carl Byington <carl@five-ten-sg.com>
date Sat, 21 Jul 2012 13:05:54 -0700 (2012-07-21)
parents 89578e4f9c87
children db12f6028f8b
files src/context.cpp src/dnsbl.cpp
diffstat 2 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/context.cpp	Sat Jul 21 12:47:19 2012 -0700
+++ b/src/context.cpp	Sat Jul 21 13:05:54 2012 -0700
@@ -854,10 +854,10 @@
 
 
 bool CONTEXT::is_unauthenticated_limited(const char *user) {
-    if (!user) return false;
     rcpt_rates::iterator i = rcpt_per_hour.find(user);  // look for sender user@email limiting
     if (i != rcpt_per_hour.end()) return true;          // found user@email limiting
     const char *f = strchr(user, '@');
+    if (!f) return false;
     i = rcpt_per_hour.find(f);                  // look for sender @domain limiting
     return (i != rcpt_per_hour.end());          // found @domain limiting
 }
--- a/src/dnsbl.cpp	Sat Jul 21 12:47:19 2012 -0700
+++ b/src/dnsbl.cpp	Sat Jul 21 13:05:54 2012 -0700
@@ -1051,11 +1051,13 @@
 //
 const char *to_lower_string(const char *email);
 const char *to_lower_string(const char *email) {
+    if (!email) return strdup("<>");
     int n = strlen(email);
+    if (n == 0) return strdup("<>");
     if (email[0] == '<') {
         // assume it also ends with >
         n -= 2;
-        if (n < 1) return strdup(email);    // return "<>"
+        if (n < 1) return strdup("<>");
         email++;
     }
     if ((email[0] == '\'') && (email[n-1] == '\'') && (n > 2)) {