mirror of
https://github.com/coredns/coredns.git
synced 2026-07-17 21:20:11 -04:00
Merge commit from fork
DoH, DoQ, and DNS-over-gRPC unpack messages without the acceptance checks used by UDP and TCP. An unauthenticated request with a large QDCOUNT can therefore force excessive allocations while names are decoded and exhaust server memory. Enforce the same request policy across all server transports. Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>
This commit is contained in:
29
plugin/pkg/dnsutil/message_test.go
Normal file
29
plugin/pkg/dnsutil/message_test.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package dnsutil
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/miekg/dns"
|
||||
)
|
||||
|
||||
func TestUnpackRequest(t *testing.T) {
|
||||
request := new(dns.Msg)
|
||||
request.SetQuestion("example.org.", dns.TypeA)
|
||||
|
||||
wire, err := request.Pack()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := UnpackRequest(wire); err != nil {
|
||||
t.Fatalf("UnpackRequest() rejected a valid request: %v", err)
|
||||
}
|
||||
|
||||
request.Question = append(request.Question, request.Question[0])
|
||||
wire, err = request.Pack()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := UnpackRequest(wire); err == nil {
|
||||
t.Fatal("UnpackRequest() accepted multiple questions")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user