mirror of
				https://github.com/coredns/coredns.git
				synced 2025-10-31 02:03:20 -04:00 
			
		
		
		
	core: drop invalid packets (#1123)
We can still be on the receiving end of invalid packet. Drop them here.
This commit is contained in:
		| @@ -179,6 +179,13 @@ func (s *Server) Address() string { return s.Addr } | |||||||
| // defined in the request so that the correct zone | // defined in the request so that the correct zone | ||||||
| // (configuration and plugin stack) will handle the request. | // (configuration and plugin stack) will handle the request. | ||||||
| func (s *Server) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) { | 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 { | 	if !s.debug { | ||||||
| 		defer func() { | 		defer func() { | ||||||
| 			// In case the user doesn't enable error plugin, we still | 			// In case the user doesn't enable error plugin, we still | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user