resolved: Increase size of TCP stub replies

DNS_PACKET_PAYLOAD_SIZE_MAX is limiting the size of the stub replies to
512 with EDNS off or 4096 with EDNS on, without checking the protocol
used. This makes TCP replies for clients without EDNS support to be
limited to 512, making the truncate flag useless if the query result is
bigger than 512 bytes.

This commit increases the size of TCP replies to DNS_PACKET_SIZE_MAX

Fixes: #10816
This commit is contained in:
Victor Tapia 2018-11-21 14:01:04 +01:00 committed by Zbigniew Jędrzejewski-Szmek
parent 59a2a18e27
commit e6eed94459

View file

@ -117,11 +117,14 @@ static inline uint16_t DNS_PACKET_RCODE(DnsPacket *p) {
static inline uint16_t DNS_PACKET_PAYLOAD_SIZE_MAX(DnsPacket *p) {
/* Returns the advertised maximum datagram size for replies, or the DNS default if there's nothing defined. */
/* Returns the advertised maximum size for replies, or the DNS default if there's nothing defined. */
if (p->opt)
return MAX(DNS_PACKET_UNICAST_SIZE_MAX, p->opt->key->class);
if (p->ipproto == IPPROTO_TCP)
return DNS_PACKET_SIZE_MAX;
return DNS_PACKET_UNICAST_SIZE_MAX;
}