Mercurial > dnsbl
changeset 328:b4f766947202
allow multiple dkim signers in authentication results
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Sun, 18 Dec 2016 17:55:16 -0800 |
parents | 51846836ec92 |
children | c9932c4d8053 |
files | src/dnsbl.cpp |
diffstat | 1 files changed, 27 insertions(+), 28 deletions(-) [+] |
line wrap: on
line diff
--- a/src/dnsbl.cpp Sun Dec 18 17:19:50 2016 -0800 +++ b/src/dnsbl.cpp Sun Dec 18 17:55:16 2016 -0800 @@ -324,7 +324,7 @@ return ip.s_addr; } } - int n = strlen(question); + size_t n = strlen(question); if (question[n-1] == '.') { priv.my_write(question, n+1); // write the question including the null terminator } @@ -1104,18 +1104,16 @@ 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++; - } - if ((email[0] == '\'') && (email[n-1] == '\'') && (n > 2)) { + size_t n = strlen(email); + if ((n > 1) && (email[0] == '<') && (email[n-1] == '>')) { n -= 2; email++; } + if ((n > 1) && (email[0] == '\'') && (email[n-1] == '\'')) { + n -= 2; + email++; + } + if (n ==0) return strdup("<>"); char *key = strdup(email); key[n] = '\0'; for (int i=0; i<n; i++) key[i] = tolower(key[i]); @@ -1458,7 +1456,7 @@ char msg[maxlen]; if ((priv.header_count < 4) || (strcasecmp(headerf, "from") == 0)) { snprintf(msg, sizeof(msg), "header %s: %s", headerf, headerv); - for (int i=0; i<strlen(msg); i++) { + for (size_t i=0; i<strlen(msg); i++) { if (msg[i] < 0x20) msg[i] = ' '; } my_syslog(&priv, msg); @@ -1472,17 +1470,17 @@ if (priv.dkim_ok) { const int nmatch = 2; regmatch_t match[nmatch]; - int offset = 0; + char *msgo = msg; while (true) { - if (0 == regexec(&dkim_pattern, msg+offset, nmatch, match, 0)) { + if (0 == regexec(&dkim_pattern, msgo, nmatch, match, 0)) { int s1 = match[1].rm_so; // domain int e1 = match[1].rm_eo; if (s1 != -1) { - char save = msg[offset+e1]; - msg[offset+e1] = '\0'; - priv.dkim_signers.insert(strdup(msg+offset+s1)); - msg[offset+e1] = save; - offset += e1 + 1; + char save = msgo[e1]; + msgo[e1] = '\0'; + priv.dkim_signers.insert(strdup(msgo+s1)); + msgo[e1] = save; + msgo += e1 + 1; } else break; } @@ -1490,6 +1488,8 @@ } } } + } + if ((priv.header_count > 2) && (strcasecmp(headerf, "from"))) { const int nmatch = 2; regmatch_t match[nmatch]; @@ -1502,7 +1502,6 @@ } } } - } // headers that avoid autowhitelisting if (((strcasecmp(headerf, "precedence") == 0) && (strcasecmp(headerv, "bulk") == 0)) ||