From d47fad8a9b62e792f6e12ffd1d03e175bb255292 Mon Sep 17 00:00:00 2001 From: Artem Glazychev Date: Wed, 31 Aug 2022 12:24:11 +0700 Subject: [PATCH] Handle empty dns answer Signed-off-by: Artem Glazychev --- pkg/tools/dnsutils/cache/handler.go | 3 +++ pkg/tools/dnsutils/fanout/handler.go | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) 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 {