diff --git a/src/edns0.c b/src/edns0.c index 3fde17f..f5b798c 100644 --- a/src/edns0.c +++ b/src/edns0.c @@ -208,7 +208,10 @@ size_t add_pseudoheader(struct dns_header *header, size_t plen, unsigned char *l free(buff); p += rdlen; } - header->arcount = htons(ntohs(header->arcount) + 1); + + /* Only bump arcount if RR is going to fit */ + if (((ssize_t)optlen) <= (limit - (p + 4))) + header->arcount = htons(ntohs(header->arcount) + 1); } if (((ssize_t)optlen) > (limit - (p + 4))) diff --git a/src/forward.c b/src/forward.c index e3fa94b..942b02d 100644 --- a/src/forward.c +++ b/src/forward.c @@ -1412,6 +1412,8 @@ void receive_query(struct listener *listen, time_t now) defaults to 512 */ if (udp_size > daemon->edns_pktsz) udp_size = daemon->edns_pktsz; + else if (udp_size < PACKETSZ) + udp_size = PACKETSZ; /* Sanity check - can't reduce below default. RFC 6891 6.2.3 */ } #ifdef HAVE_AUTH