Skip to content

Commit bea32b0

Browse files
committed
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>
1 parent bf2bd42 commit bea32b0

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

resolver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ func (r *resolver) ServeDNS(w dns.ResponseWriter, query *dns.Msg) {
484484
resp, err = co.ReadMsg()
485485
// Truncated DNS replies should be sent to the client so that the
486486
// client can retry over TCP
487-
if err != nil && !resp.Truncated {
487+
if err != nil && (resp != nil && !resp.Truncated) {
488488
r.forwardQueryEnd()
489489
logrus.Debugf("[resolver] read from DNS server failed, %s", err)
490490
continue

0 commit comments

Comments
 (0)