From 6c2637be1142b2ed537795d960952414ffc73a58 Mon Sep 17 00:00:00 2001 From: er0k Date: Sat, 11 Feb 2023 15:14:03 -0500 Subject: [PATCH] Do not log connection info before the connection exists If the resolver encounters an error before it attempts to forward the request to external DNS, do not try to log information about the external connection, because at this point `extConn` is `nil`. This makes sure `dockerd` won't panic and crash from a nil pointer dereference when it sees an invalid DNS query. fixes #44979 Signed-off-by: er0k --- libnetwork/resolver.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libnetwork/resolver.go b/libnetwork/resolver.go index ff578356e5..1c05afc608 100644 --- a/libnetwork/resolver.go +++ b/libnetwork/resolver.go @@ -396,7 +396,7 @@ func (r *resolver) ServeDNS(w dns.ResponseWriter, query *dns.Msg) { } if err != nil { - logrus.WithError(err).Errorf("[resolver] failed to handle query: %s (%s) from %s", queryName, dns.TypeToString[queryType], extConn.LocalAddr().String()) + logrus.WithError(err).Errorf("[resolver] failed to handle query: %s (%s)", queryName, dns.TypeToString[queryType]) return }