diff src/dnsbl.cpp @ 346:66969443a012

need to strip <> from recipient address before sending to verifier
author Carl Byington <carl@five-ten-sg.com>
date Fri, 23 Dec 2016 09:35:10 -0800
parents 891281cb6d3d
children 8fe6d5120771
line wrap: on
line diff
--- a/src/dnsbl.cpp	Fri Dec 23 08:20:53 2016 -0800
+++ b/src/dnsbl.cpp	Fri Dec 23 09:35:10 2016 -0800
@@ -1101,8 +1101,8 @@
 // to lower case. Some clients enclose the entire address in single quotes,
 // so we strip those as well. We also remove the SRS and prvs coding.
 //
-const char *to_lower_string(const char *email);
-const char *to_lower_string(const char *email) {
+const char *to_lower_string(const char *email, bool srs = true);
+const char *to_lower_string(const char *email, bool srs) {
     if (!email) return strdup("<>");
     size_t n = strlen(email);
     if ((n > 1) && (email[0] == '<') && (email[n-1] == '>')) {
@@ -1117,6 +1117,8 @@
     char *key = strdup(email);
     key[n] = '\0';
     for (size_t i=0; i<n; i++) key[i] = tolower(key[i]);
+
+    if (srs) {
     if ((n > 14) && (strncmp(key, "srs", 3) == 0)) {
         // might have srs coding to be removed
         const int nmatch = 7;
@@ -1151,6 +1153,7 @@
             }
         }
     }
+    }
     return key;
 }
 
@@ -1365,7 +1368,9 @@
 
     if (ver) {
         // try to verify this from/to pair of addresses even if it might be explicitly whitelisted
+        const char *loto = to_lower_string(rcptaddr, false);
         bool rc = ver->ok(priv.queueid, priv.mailaddr, rcptaddr);
+        free((void*)loto);
         if (!rc) {
             smfi_setreply(ctx, (char*)"550", (char*)"5.7.1", (char*)"no such user");
             return SMFIS_REJECT;