From 79bd67a6c4e0c4b69b9d47cef888e7df56dd1d8c Mon Sep 17 00:00:00 2001 From: gVisor bot Date: Wed, 11 Jan 2023 09:53:56 +0800 Subject: [PATCH] fix: dns cache index out of range --- dns/util.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/dns/util.go b/dns/util.go index 8259f22e..e53abab0 100644 --- a/dns/util.go +++ b/dns/util.go @@ -29,9 +29,11 @@ const ( func putMsgToCache(c *cache.LruCache[string, *D.Msg], key string, msg *D.Msg) { // skip dns cache for acme challenge - if q := msg.Question[0]; q.Qtype == D.TypeTXT && strings.HasPrefix(q.Name, "_acme-challenge") { - log.Debugln("[DNS] dns cache ignored because of acme challenge for: %s", q.Name) - return + if len(msg.Question) != 0 { + if q := msg.Question[0]; q.Qtype == D.TypeTXT && strings.HasPrefix(q.Name, "_acme-challenge") { + log.Debugln("[DNS] dns cache ignored because of acme challenge for: %s", q.Name) + return + } } var ttl uint32 switch {