mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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>
This commit is contained in:
parent
e85ffec784
commit
f0e940ebc9
2 changed files with 55 additions and 0 deletions
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue