]> Cypherpunks repositories - gostls13.git/commitdiff
net: increase maximum accepted DNS packet to 1232 bytes
authorIan Lance Taylor <iant@golang.org>
Tue, 15 Feb 2022 21:40:49 +0000 (13:40 -0800)
committerIan Lance Taylor <iant@golang.org>
Tue, 15 Feb 2022 22:30:13 +0000 (22:30 +0000)
The existing value of 512 bytes as is specified by RFC 1035.
However, the WSL resolver reportedly sends larger packets without
setting the truncation bit, which breaks using the Go resolver.
For 1.18 and backports, just increase the accepted packet size.
This is what GNU glibc does (they use 65536 bytes).

For 1.19 we plan to use EDNS to set the accepted packet size.
That will give us more time to test whether that causes any problems.

No test because I'm not sure how to write one and it wouldn't really
be useful anyhow.

Fixes #6464
Fixes #21160
Fixes #44135
Fixes #51127
For #51153

Change-Id: I0243f274a06e010ebb714e138a65386086aecf17
Reviewed-on: https://go-review.googlesource.com/c/go/+/386015
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

src/net/dnsclient_unix.go
src/net/dnsclient_unix_test.go

index 21aa91f665ad3d481bd3dd22672fd1903b0e0096..9a4a6ee68c89174919e7f6647f4b6536e12256e3 100644 (file)
@@ -30,6 +30,10 @@ const (
        // to be used as a useTCP parameter to exchange
        useTCPOnly  = true
        useUDPOrTCP = false
+
+       // Maximum DNS packet size.
+       // Value taken from https://dnsflagday.net/2020/.
+       maxDNSPacketSize = 1232
 )
 
 var (
@@ -82,7 +86,7 @@ func dnsPacketRoundTrip(c Conn, id uint16, query dnsmessage.Question, b []byte)
                return dnsmessage.Parser{}, dnsmessage.Header{}, err
        }
 
-       b = make([]byte, 512) // see RFC 1035
+       b = make([]byte, maxDNSPacketSize)
        for {
                n, err := c.Read(b)
                if err != nil {
index 14366eca8c63b100eb05c6a5cfefa12cc5f66c76..e46decab16c98a8828edf7d488d6d78102788b6a 100644 (file)
@@ -881,7 +881,7 @@ func (f *fakeDNSPacketConn) Close() error {
 func TestIgnoreDNSForgeries(t *testing.T) {
        c, s := Pipe()
        go func() {
-               b := make([]byte, 512)
+               b := make([]byte, maxDNSPacketSize)
                n, err := s.Read(b)
                if err != nil {
                        t.Error(err)