You need to sign in or sign up before continuing.
Commit 9f49d694 authored by Miek Gieben's avatar Miek Gieben Committed by corbot[bot]

fuzz: fix rewrite crash by fixing fuzz/do.go (#3178)

Automatically submitted.
parent f8e0ae63
...@@ -13,15 +13,19 @@ import ( ...@@ -13,15 +13,19 @@ import (
// Do will fuzz p - used by gofuzz. See Makefile.fuzz for comments and context. // Do will fuzz p - used by gofuzz. See Makefile.fuzz for comments and context.
func Do(p plugin.Handler, data []byte) int { func Do(p plugin.Handler, data []byte) int {
ctx := context.TODO() ctx := context.TODO()
ret := 1
r := new(dns.Msg) r := new(dns.Msg)
if err := r.Unpack(data); err != nil { if err := r.Unpack(data); err != nil {
ret = 0 return 0 // plugin will never be called when this happens.
}
// If the data unpack into a dns msg, but does not have a proper question section discard it.
// The server parts make sure this is true before calling the plugins; mimic this behavior.
if len(r.Question) == 0 {
return 0
} }
if _, err := p.ServeDNS(ctx, &test.ResponseWriter{}, r); err != nil { if _, err := p.ServeDNS(ctx, &test.ResponseWriter{}, r); err != nil {
ret = 1 return 1
} }
return ret return 0
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment