mirror of
https://github.com/coredns/coredns.git
synced 2025-11-15 16:32:23 -05:00
* 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
28 lines
538 B
Go
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
|
|
}
|