Forráskód Böngészése

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>
Sam Whited 5 éve
szülő
commit
1e02aae252
1 módosított fájl, 1 hozzáadás és 1 törlés
  1. 1 1
      libnetwork/resolver.go

+ 1 - 1
libnetwork/resolver.go

@@ -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