Mercurial > dnsbl
comparison src/dnsbl.cpp @ 327:51846836ec92
allow multiple dkim signers in authentication results
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Sun, 18 Dec 2016 17:19:50 -0800 |
parents | 5e4b5540c8cc |
children | b4f766947202 |
comparison
equal
deleted
inserted
replaced
326:5e4b5540c8cc | 327:51846836ec92 |
---|---|
1470 if (strcasecmp(headerf, "Authentication-Results") != 0) priv.dkim_ok = false; | 1470 if (strcasecmp(headerf, "Authentication-Results") != 0) priv.dkim_ok = false; |
1471 if (strncasecmp(headerv, token_myhostname, strlen(token_myhostname)) != 0) priv.dkim_ok = false; | 1471 if (strncasecmp(headerv, token_myhostname, strlen(token_myhostname)) != 0) priv.dkim_ok = false; |
1472 if (priv.dkim_ok) { | 1472 if (priv.dkim_ok) { |
1473 const int nmatch = 2; | 1473 const int nmatch = 2; |
1474 regmatch_t match[nmatch]; | 1474 regmatch_t match[nmatch]; |
1475 int offset = 0; | |
1475 while (true) { | 1476 while (true) { |
1476 if (0 == regexec(&dkim_pattern, msg, nmatch, match, 0)) { | 1477 if (0 == regexec(&dkim_pattern, msg+offset, nmatch, match, 0)) { |
1477 int s1 = match[1].rm_so; // domain | 1478 int s1 = match[1].rm_so; // domain |
1478 int e1 = match[1].rm_eo; | 1479 int e1 = match[1].rm_eo; |
1479 if (s1 != -1) { | 1480 if (s1 != -1) { |
1480 msg[e1] = '\0'; | 1481 char save = msg[offset+e1]; |
1481 priv.dkim_signers.insert(strdup(msg+s1)); | 1482 msg[offset+e1] = '\0'; |
1483 priv.dkim_signers.insert(strdup(msg+offset+s1)); | |
1484 msg[offset+e1] = save; | |
1485 offset += e1 + 1; | |
1482 } | 1486 } |
1487 else break; | |
1483 } | 1488 } |
1484 else break; | 1489 else break; |
1485 } | 1490 } |
1486 } | 1491 } |
1487 } | 1492 } |
1858 printf("cannot compile regex pattern to find prvs coding in mail addresses\n"); | 1863 printf("cannot compile regex pattern to find prvs coding in mail addresses\n"); |
1859 exit(3); | 1864 exit(3); |
1860 } | 1865 } |
1861 | 1866 |
1862 // setup dkim signature detection | 1867 // setup dkim signature detection |
1863 if (regcomp(&dkim_pattern, " dkim=pass .* header.d=([^ ]+) ", REG_ICASE | REG_EXTENDED)) { | 1868 if (regcomp(&dkim_pattern, " dkim=pass .[0-9]*-bit key. header.d=([^ ]+) ", REG_ICASE | REG_EXTENDED)) { |
1864 printf("cannot compile regex pattern to find dkim signatures\n"); | 1869 printf("cannot compile regex pattern to find dkim signatures\n"); |
1865 exit(3); | 1870 exit(3); |
1866 } | 1871 } |
1867 | 1872 |
1868 // setup from domain extraction | 1873 // setup from domain extraction |