From 27e22b069683b4477b4509d88ea57c8963e90ad1 Mon Sep 17 00:00:00 2001 From: Miek Gieben Date: Wed, 25 Sep 2019 18:18:54 +0100 Subject: [PATCH] Use strings.ToLower in server (#3304) Automatically submitted. --- core/dnsserver/server.go | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/core/dnsserver/server.go b/core/dnsserver/server.go index a0d9bbc3a..587f219dd 100644 --- a/core/dnsserver/server.go +++ b/core/dnsserver/server.go @@ -6,6 +6,7 @@ import ( "fmt" "net" "runtime" + "strings" "sync" "time" @@ -217,27 +218,18 @@ func (s *Server) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) return } - q := r.Question[0].Name - b := make([]byte, len(q)) - var off int - var end bool - - var dshandler *Config - // Wrap the response writer in a ScrubWriter so we automatically make the reply fit in the client's buffer. w = request.NewScrubWriter(r, w) - for { - l := len(q[off:]) - for i := 0; i < l; i++ { - b[i] = q[off+i] - // normalize the name for the lookup - if b[i] >= 'A' && b[i] <= 'Z' { - b[i] |= ('a' - 'A') - } - } + q := strings.ToLower(r.Question[0].Name) + var ( + off int + end bool + dshandler *Config + ) - if h, ok := s.zones[string(b[:l])]; ok { + for { + if h, ok := s.zones[q[off:]]; ok { if r.Question[0].Qtype != dns.TypeDS { if h.FilterFunc == nil { rcode, _ := h.pluginChain.ServeDNS(ctx, w, r)