comparison src/context.cpp @ 428:6f2db3d19a34 stable-6-0-61

allow 4000 byte spf txt records
author Carl Byington <carl@five-ten-sg.com>
date Mon, 02 Oct 2017 15:09:55 -0700
parents c9b7b6dd1206
children 69d33c034a8e
comparison
equal deleted inserted replaced
427:9911e362b5dc 428:6f2db3d19a34
1169 } 1169 }
1170 1170
1171 1171
1172 bool CONTEXT::resolve_one_spf(const char *from, uint32_t ip, mlfiPriv *priv, int level) 1172 bool CONTEXT::resolve_one_spf(const char *from, uint32_t ip, mlfiPriv *priv, int level)
1173 { 1173 {
1174 char buf[maxlen]; 1174 char buf[maxdnslength];
1175 log(priv->queueid, "looking for %s txt record", from); 1175 log(priv->queueid, "looking for %s txt record", from);
1176 dns_interface(*priv, from, ns_t_txt, false, NULL, buf, maxlen); 1176 dns_interface(*priv, from, ns_t_txt, false, NULL, buf, maxdnslength);
1177 if (*buf) { 1177 if (*buf) {
1178 log(priv->queueid, "found txt record %s", buf); 1178 log(priv->queueid, "found txt record %s", buf);
1179 // expand some macros here - a very restricted subset of all possible spf macros 1179 // expand some macros here - a very restricted subset of all possible spf macros
1180 // only expand the first instance of each. 1180 // only expand the first instance of each.
1181 char *p = strstr(buf, "%{i}"); 1181 char *p = strstr(buf, "%{i}");
1229 else if (strncmp(p, "all", 3) == 0) { 1229 else if (strncmp(p, "all", 3) == 0) {
1230 // ignore it before looking for (a or a:) below 1230 // ignore it before looking for (a or a:) below
1231 } 1231 }
1232 else if (strncmp(p, "exists:", 7) == 0) { 1232 else if (strncmp(p, "exists:", 7) == 0) {
1233 p += 7; 1233 p += 7;
1234 char buf[maxlen]; 1234 char buf[maxdnslength];
1235 dns_interface(*priv, p, ns_t_a, false, NULL, buf, maxlen); 1235 dns_interface(*priv, p, ns_t_a, false, NULL, buf, maxdnslength);
1236 uint32_t *a = (uint32_t *)buf; 1236 uint32_t *a = (uint32_t *)buf;
1237 if (a[0]) { 1237 if (a[0]) {
1238 log(priv->queueid, "match exists:%s", p); 1238 log(priv->queueid, "match exists:%s", p);
1239 return true; 1239 return true;
1240 } 1240 }
1241 } 1241 }
1242 else if (strncmp(p, "mx", 2) == 0) { 1242 else if (strncmp(p, "mx", 2) == 0) {
1243 const char *name = (p[2] == ':') ? p+2 : from; 1243 const char *name = (p[2] == ':') ? p+2 : from;
1244 char buf[maxlen]; 1244 char buf[maxdnslength];
1245 dns_interface(*priv, name, ns_t_mx, false, NULL, buf, maxlen); 1245 dns_interface(*priv, name, ns_t_mx, false, NULL, buf, maxdnslength);
1246 char *b = buf; 1246 char *b = buf;
1247 while (*b) { 1247 while (*b) {
1248 log(priv->queueid, "found mx %s", b); 1248 log(priv->queueid, "found mx %s", b);
1249 char buf[maxlen]; 1249 char buf[maxdnslength];
1250 dns_interface(*priv, b, ns_t_a, false, NULL, buf, maxlen); 1250 dns_interface(*priv, b, ns_t_a, false, NULL, buf, maxdnslength);
1251 uint32_t *a = (uint32_t *)buf; 1251 uint32_t *a = (uint32_t *)buf;
1252 size_t c = a[0]; 1252 size_t c = a[0];
1253 for (size_t i=1; i<=c; i++) { 1253 for (size_t i=1; i<=c; i++) {
1254 uint32_t ipy = ntohl(a[i]); 1254 uint32_t ipy = ntohl(a[i]);
1255 char adr[sizeof "255.255.255.255 "]; //!! 1255 char adr[sizeof "255.255.255.255 "]; //!!
1264 b += strlen(b) + 1; 1264 b += strlen(b) + 1;
1265 } 1265 }
1266 } 1266 }
1267 else if (p[0] == 'a') { 1267 else if (p[0] == 'a') {
1268 const char *name = (p[1] == ':') ? p+2 : from; 1268 const char *name = (p[1] == ':') ? p+2 : from;
1269 char buf[maxlen]; 1269 char buf[maxdnslength];
1270 dns_interface(*priv, name, ns_t_a, false, NULL, buf, maxlen); 1270 dns_interface(*priv, name, ns_t_a, false, NULL, buf, maxdnslength);
1271 uint32_t *a = (uint32_t *)buf; 1271 uint32_t *a = (uint32_t *)buf;
1272 size_t c = a[0]; 1272 size_t c = a[0];
1273 for (size_t i=1; i<=c; i++) { 1273 for (size_t i=1; i<=c; i++) {
1274 uint32_t ipy = ntohl(a[i]); 1274 uint32_t ipy = ntohl(a[i]);
1275 if (ipy == ip) { 1275 if (ipy == ip) {