aboutsummaryrefslogtreecommitdiff
path: root/src/net/dnsclient_unix.go
diff options
context:
space:
mode:
authorMichael Hendricks <michael@ndrix.org>2019-10-02 09:30:51 -0600
committerBrad Fitzpatrick <bradfitz@golang.org>2019-10-02 20:54:54 +0000
commitf0e940ebc985661f54d31c8d9ba31a553b87041b (patch)
tree03b9f5d676aad4ac1ac524664a9be0b1aade56ce /src/net/dnsclient_unix.go
parente85ffec784b867f016805873eec5dc91eec1c99a (diff)
downloadgo-f0e940ebc985661f54d31c8d9ba31a553b87041b.tar.gz
go-f0e940ebc985661f54d31c8d9ba31a553b87041b.zip
net: avoid an infinite loop in LookupAddr
If a request for a PTR record returned a response with a non-PTR answer, goLookupPTR would loop forever. Skipping non-PTR answers guarantees progress through the DNS response. Fixes #34660 Change-Id: I56f9d21e5342d07e7d843d253267e93a29707904 Reviewed-on: https://go-review.googlesource.com/c/go/+/198460 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/net/dnsclient_unix.go')
-rw-r--r--src/net/dnsclient_unix.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/net/dnsclient_unix.go b/src/net/dnsclient_unix.go
index e0a7ef85521..c90892b8330 100644
--- a/src/net/dnsclient_unix.go
+++ b/src/net/dnsclient_unix.go
@@ -765,6 +765,14 @@ func (r *Resolver) goLookupPTR(ctx context.Context, addr string) ([]string, erro
}
}
if h.Type != dnsmessage.TypePTR {
+ err := p.SkipAnswer()
+ if err != nil {
+ return nil, &DNSError{
+ Err: "cannot marshal DNS message",
+ Name: addr,
+ Server: server,
+ }
+ }
continue
}
ptr, err := p.PTRResource()