diff options
author | 2017-09-29 22:27:40 +0100 | |
---|---|---|
committer | 2017-09-29 22:27:40 +0100 | |
commit | 23526aec1d933b6362c80eaa084749a794d43aca (patch) | |
tree | 5cf0f4a441037c6acac4305a45e7c9ae517ae673 | |
parent | 2f9c42d82ec5e2edd475e8166547ad7a89ca4f1d (diff) | |
download | coredns-23526aec1d933b6362c80eaa084749a794d43aca.tar.gz coredns-23526aec1d933b6362c80eaa084749a794d43aca.tar.zst coredns-23526aec1d933b6362c80eaa084749a794d43aca.zip |
core: drop invalid packets (#1123)
We can still be on the receiving end of invalid packet. Drop them
here.
-rw-r--r-- | core/dnsserver/server.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/core/dnsserver/server.go b/core/dnsserver/server.go index f24b1dd60..721fd216e 100644 --- a/core/dnsserver/server.go +++ b/core/dnsserver/server.go @@ -179,6 +179,13 @@ func (s *Server) Address() string { return s.Addr } // defined in the request so that the correct zone // (configuration and plugin stack) will handle the request. func (s *Server) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) { + // our dns library protects us against really invalid packets, we can still + // get semi valid packets. Drop them here. + if r == nil || len(r.Question) == 0 { + DefaultErrorFunc(w, r, dns.RcodeServerFailure) + return + } + if !s.debug { defer func() { // In case the user doesn't enable error plugin, we still |