comparison src/dnsbl.cpp @ 334:a4f2fda72422

missing ==0 testing for from header, we were scanning all the non-from headers
author Carl Byington <carl@five-ten-sg.com>
date Tue, 20 Dec 2016 09:20:15 -0800
parents 89574f8a2f64
children 354b15b8b263
comparison
equal deleted inserted replaced
333:89574f8a2f64 334:a4f2fda72422
1498 } 1498 }
1499 } 1499 }
1500 } 1500 }
1501 } 1501 }
1502 1502
1503 if ((priv.header_count > 2) && (strcasecmp(headerf, "from"))) { 1503 // only look at the first from header
1504 if ((priv.header_count > 2) && (!priv.fromaddr) && (strcasecmp(headerf, "from") == 0)) {
1504 const int nmatch = 2; 1505 const int nmatch = 2;
1505 regmatch_t match[nmatch]; 1506 regmatch_t match[nmatch];
1506 int err = regexec(&from_pattern, msg, nmatch, match, 0); 1507 int err = regexec(&from_pattern, msg, nmatch, match, 0);
1507 if (err == 0) { 1508 if (err == 0) {
1508 int s1 = match[1].rm_so; // domain 1509 int s1 = match[1].rm_so; // domain
1509 int e1 = match[1].rm_eo; 1510 int e1 = match[1].rm_eo;
1510 if (s1 != -1) { 1511 if (s1 != -1) {
1511 msg[e1] = '\0'; 1512 msg[e1] = '\0';
1512 priv.fromaddr = strdup(msg+s1); 1513 priv.fromaddr = strdup(msg+s1);
1513 } 1514 }
1514 }
1515 else {
1516 char buf[maxlen];
1517 size_t n = regerror(err, &from_pattern, buf, maxlen);
1518 my_syslog(&priv, buf);
1519 } 1515 }
1520 } 1516 }
1521 1517
1522 // headers that avoid autowhitelisting 1518 // headers that avoid autowhitelisting
1523 if (((strcasecmp(headerf, "precedence") == 0) && (strcasecmp(headerv, "bulk") == 0)) || 1519 if (((strcasecmp(headerf, "precedence") == 0) && (strcasecmp(headerv, "bulk") == 0)) ||