diff src/dnsbl.cpp @ 335:354b15b8b263

header from may appear very early in unsigned messages
author Carl Byington <carl@five-ten-sg.com>
date Tue, 20 Dec 2016 16:54:32 -0800
parents a4f2fda72422
children d68fda9be1c1
line wrap: on
line diff
--- a/src/dnsbl.cpp	Tue Dec 20 09:20:15 2016 -0800
+++ b/src/dnsbl.cpp	Tue Dec 20 16:54:32 2016 -0800
@@ -1463,15 +1463,6 @@
 {
     mlfiPriv &priv = *MLFIPRIV;
     priv.header_count++;
-    char msg[maxlen];
-    if ((priv.header_count < 4) || (strcasecmp(headerf, "from") == 0)) {
-        snprintf(msg, sizeof(msg), "header %s: %s", headerf, headerv);
-        for (size_t i=0; i<strlen(msg); i++) {
-            if (msg[i] < 0x20) msg[i] = ' ';
-        }
-        my_syslog(&priv, msg);
-    }
-
     if (priv.dkim_ok) {
         if ((priv.header_count == 1) && (strcasecmp(headerf, "DKIM-Filter") != 0)) priv.dkim_ok = false;
         if (priv.header_count == 2) {
@@ -1480,7 +1471,7 @@
             if (priv.dkim_ok) {
                 const int nmatch = 2;
                 regmatch_t match[nmatch];
-                char *msgo = msg;
+                char *msgo = headerv;
                 while (true) {
                     if (0 == regexec(&dkim_pattern, msgo, nmatch, match, 0)) {
                         int s1 = match[1].rm_so;    // domain
@@ -1501,16 +1492,18 @@
     }
 
     // only look at the first from header
-    if ((priv.header_count > 2) && (!priv.fromaddr) && (strcasecmp(headerf, "from") == 0)) {
+    if ((!priv.fromaddr) && (strcasecmp(headerf, "from") == 0)) {
         const int nmatch = 2;
         regmatch_t match[nmatch];
-        int err = regexec(&from_pattern, msg, nmatch, match, 0);
+        int err = regexec(&from_pattern, headerv, nmatch, match, 0);
         if (err == 0) {
             int s1 = match[1].rm_so;    // domain
             int e1 = match[1].rm_eo;
             if (s1 != -1) {
-                msg[e1] = '\0';
-                priv.fromaddr = strdup(msg+s1);
+                char save = headerv[e1];
+                headerv[e1] = '\0';
+                priv.fromaddr = strdup(headerv+s1);
+                headerv[e1] = save;
             }
         }
     }