From a0ec0b2b5705a6807fd99c89777fd8f8b79dee5f Mon Sep 17 00:00:00 2001 From: Eugene Burkov Date: Wed, 6 Dec 2023 12:10:39 +0300 Subject: [PATCH] Pull request 2095: fix nil deref Squashed commit of the following: commit 74089af1bb05892ac5c1e4dfefde6256e1b55c02 Author: Eugene Burkov Date: Tue Dec 5 20:50:12 2023 +0300 dnsforward: fix nil deref --- internal/dnsforward/dnsforward.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/dnsforward/dnsforward.go b/internal/dnsforward/dnsforward.go index f9ac8723..8afbd3df 100644 --- a/internal/dnsforward/dnsforward.go +++ b/internal/dnsforward/dnsforward.go @@ -247,7 +247,6 @@ func NewServer(p DNSCreateParams) (s *Server, err error) { privateNets: p.PrivateNets, // TODO(e.burkov): Use some case-insensitive string comparison. localDomainSuffix: strings.ToLower(localDomainSuffix), - etcHosts: p.EtcHosts, recDetector: newRecursionDetector(recursionTTL, cachedRecurrentReqNum), clientIDCache: cache.New(cache.Config{ EnableLRU: true, @@ -258,6 +257,9 @@ func NewServer(p DNSCreateParams) (s *Server, err error) { ServePlainDNS: true, }, } + if p.EtcHosts != nil { + s.etcHosts = p.EtcHosts + } s.sysResolvers, err = sysresolv.NewSystemResolvers(nil, defaultPlainDNSPort) if err != nil {