1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Fixes a panic in the DNS resolver

Under certain conditions it appears that the DNS response and returned
error can be nil. When this happens, checking resp.Truncated results in
a nil panic so we must first check that the response is not nil before
checking if a truncated response was received.

See moby/moby#40715

Signed-off-by: Sam Whited <sam@samwhited.com>
This commit is contained in:
Sam Whited 2020-03-18 12:06:23 -04:00
parent c485bbf754
commit 1e02aae252

View file

@ -484,7 +484,7 @@ func (r *resolver) ServeDNS(w dns.ResponseWriter, query *dns.Msg) {
resp, err = co.ReadMsg()
// Truncated DNS replies should be sent to the client so that the
// client can retry over TCP
if err != nil && !resp.Truncated {
if err != nil && (resp != nil && !resp.Truncated) {
r.forwardQueryEnd()
logrus.Debugf("[resolver] read from DNS server failed, %s", err)
continue