Files
coredns/plugin/pkg/fuzz/do.go
Miek Gieben 8722336fff global: move to context (#1699)
* global: move to context

Move from golang.org/x/net/context to std lib's context.

Change done with:

for i in $(grep -l '/context' **/*.go); do sed -e 's|golang.org/x/net/context|context|' -i $i; echo $i; done
for i in **/*.go; do goimports -w $i; done

* drop from dns.pb.go as well
2018-04-20 11:01:06 +01:00

28 lines
538 B
Go

// Package fuzz contains functions that enable fuzzing of plugins.
package fuzz
import (
"github.com/coredns/coredns/plugin"
"github.com/coredns/coredns/plugin/test"
"context"
"github.com/miekg/dns"
)
// Do will fuzz p - used by gofuzz. See Maefile.fuzz for comments and context.
func Do(p plugin.Handler, data []byte) int {
ctx := context.TODO()
ret := 1
r := new(dns.Msg)
if err := r.Unpack(data); err != nil {
ret = 0
}
if _, err := p.ServeDNS(ctx, &test.ResponseWriter{}, r); err != nil {
ret = 1
}
return ret
}