comparison src/dnsbl.cpp @ 419:91f2a127ec69 stable-6-0-57

spf code now handles mx,exists,ptr tags, multiple A records, %{i} macro
author Carl Byington <carl@five-ten-sg.com>
date Wed, 26 Apr 2017 09:20:35 -0700
parents 16451edcb962
children 1b7a785610f5
comparison
equal deleted inserted replaced
418:ea4f86e2db42 419:91f2a127ec69
304 // and if my_answer is non-null, all the ip addresses are returned in 304 // and if my_answer is non-null, all the ip addresses are returned in
305 // my_answer (in network byte order), prepended with the count. 305 // my_answer (in network byte order), prepended with the count.
306 // IP address 0 is returned in case of errors. 306 // IP address 0 is returned in case of errors.
307 // 307 //
308 uint32_t dns_interface(mlfiPriv &priv, const char *question, int qtype, bool maybe_ip, ns_map *nameservers, char *my_answer, size_t my_size) { 308 uint32_t dns_interface(mlfiPriv &priv, const char *question, int qtype, bool maybe_ip, ns_map *nameservers, char *my_answer, size_t my_size) {
309 if (my_answer) my_answer[0] = '\0'; // return null string if there are no txt answers 309 // return null string if there are no txt answers
310 // return zero count if there are no a answers
311 if (my_answer && my_size) memset(my_answer, 0, my_size);
310 312
311 // tell sendmail we are still working 313 // tell sendmail we are still working
312 #if _FFR_SMFI_PROGRESS 314 #if _FFR_SMFI_PROGRESS
313 if (priv.eom) smfi_progress(priv.ctx); 315 if (priv.eom) smfi_progress(priv.ctx);
314 #endif 316 #endif
436 if (ns_rr_type(rr) == qtype) { 438 if (ns_rr_type(rr) == qtype) {
437 char exchange[NS_MAXDNAME]; 439 char exchange[NS_MAXDNAME];
438 //size_t rdlen = ns_rr_rdlen(rr); 440 //size_t rdlen = ns_rr_rdlen(rr);
439 //const uint16_t pri = ns_get16(rdata); 441 //const uint16_t pri = ns_get16(rdata);
440 const unsigned char *rdata = ns_rr_rdata(rr); 442 const unsigned char *rdata = ns_rr_rdata(rr);
441 int len = dn_expand(glom.answer, glom.answer+glom.length, rdata + 2, exchange, sizeof(exchange)); 443 int len = dn_expand(ns_msg_base(handle), ns_msg_base(handle) + ns_msg_size(handle), rdata + NS_INT16SZ, exchange, sizeof(exchange));
442 if ((len > 0) && (my_size > (uint32_t)len+2)) { 444 if (len > 0) { // no error
443 strcpy(my_answer, exchange); 445 len = strlen(exchange) + 1;
444 my_answer += len + 1; 446 if (my_size >= (uint32_t)len+1) {
445 my_size -= len + 1; 447 strcpy(my_answer, exchange);
446 c++; 448 my_answer += len;
449 my_size -= len;
450 c++;
451 }
447 } 452 }
448 } 453 }
449 } 454 }
450 *my_answer = '\0'; // final trailing null 455 *my_answer = '\0'; // final trailing null
451 ret_address = htonl(c); 456 ret_address = htonl(c);