diff --git a/pkg/tools/dnsutils/cache/handler.go b/pkg/tools/dnsutils/cache/handler.go index da1032b7b..1bbc7ea03 100644 --- a/pkg/tools/dnsutils/cache/handler.go +++ b/pkg/tools/dnsutils/cache/handler.go @@ -85,6 +85,9 @@ func (h *dnsCacheHandler) updateTTL() { } func validateMsg(m *dns.Msg) bool { + if len(m.Answer) == 0 { + return false + } for _, answer := range m.Answer { if answer.Header().Ttl <= 0 { return false diff --git a/pkg/tools/dnsutils/fanout/handler.go b/pkg/tools/dnsutils/fanout/handler.go index 10dc550fe..7d2d9e14e 100644 --- a/pkg/tools/dnsutils/fanout/handler.go +++ b/pkg/tools/dnsutils/fanout/handler.go @@ -102,7 +102,7 @@ func (h *fanoutHandler) waitResponse(ctx context.Context, respCh <-chan *dns.Msg } continue } - if resp.Rcode == dns.RcodeSuccess { + if resp.Rcode == dns.RcodeSuccess && len(resp.Answer) != 0 { return resp } if respCount == 0 {