From 1571609e5975be22e31d3ef7336a4ac6b1f08880 Mon Sep 17 00:00:00 2001 From: Ainar Garipov Date: Tue, 6 Jul 2021 15:08:55 +0300 Subject: [PATCH] Pull request #1238: dnsforward: fix panic Updates #3318. Squashed commit of the following: commit eebaa3ac3a6bfcb29e280006ead8ea9554b8a3bf Author: Ainar Garipov Date: Tue Jul 6 14:59:00 2021 +0300 dnsforward: imp code commit 7591a3b183ab95f27f908267321518740cb7d4bb Author: Ainar Garipov Date: Tue Jul 6 14:55:33 2021 +0300 dnsforward: fix panic --- internal/dnsforward/dns.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/internal/dnsforward/dns.go b/internal/dnsforward/dns.go index 657afe6b..120c1d64 100644 --- a/internal/dnsforward/dns.go +++ b/internal/dnsforward/dns.go @@ -379,15 +379,17 @@ func (s *Server) ipToHost(ip net.IP) (host string, ok bool) { var v interface{} v, ok = s.tableIPToHost.Get(ip) + if !ok { + return "", false + } - var typOK bool - if host, typOK = v.(string); !typOK { + if host, ok = v.(string); !ok { log.Error("dns: bad type %T in tableIPToHost for %s", v, ip) return "", false } - return host, ok + return host, true } // Respond to PTR requests if the target IP is leased by our DHCP server and the