resolved: Increase size of TCP stub replies
authorVictor Tapia <victor.tapia@canonical.com>
Wed, 21 Nov 2018 13:01:04 +0000 (14:01 +0100)
committerFelipe Sateler <fsateler@debian.org>
Thu, 6 Dec 2018 00:03:34 +0000 (00:03 +0000)
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
(cherry picked from commit e6eed9445956cfa496e1db933bfd3530db23bfce)

Gbp-Pq: Name resolved-Increase-size-of-TCP-stub-replies.patch

src/resolve/resolved-dns-packet.h

index 8e9d74a71a07b3cd1c9cbc53963ac897cd327870..22ef871b036eaa8b6c49a4a0e0c5351e33cb31f9 100644 (file)
@@ -120,11 +120,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;
 }