From e08d3335b0014e5fa9ef6ff239ca3f4d2122f658 Mon Sep 17 00:00:00 2001 From: Miek Gieben Date: Sun, 25 Aug 2019 19:01:35 +0000 Subject: [PATCH] fuzz: revert setup function (#3189) This can't be used in its current form; revert the entire PR. Revert "fuzzing: allow setup function to be called (#3175)" This reverts commit 62451fd3eb68cef5dcdafe6e4228f08cf52d84fc. --- plugin/cache/fuzz.go | 2 +- plugin/chaos/fuzz.go | 2 +- plugin/file/fuzz.go | 2 +- plugin/pkg/fuzz/do.go | 7 +------ plugin/pkg/fuzz/setup.go | 10 ---------- plugin/rewrite/fuzz.go | 2 +- plugin/whoami/fuzz.go | 2 +- 7 files changed, 6 insertions(+), 21 deletions(-) delete mode 100644 plugin/pkg/fuzz/setup.go diff --git a/plugin/cache/fuzz.go b/plugin/cache/fuzz.go index 368953bbf..18e98fa9f 100644 --- a/plugin/cache/fuzz.go +++ b/plugin/cache/fuzz.go @@ -8,5 +8,5 @@ import ( // Fuzz fuzzes cache. func Fuzz(data []byte) int { - return fuzz.Do(New(), nil, data) + return fuzz.Do(New(), data) } diff --git a/plugin/chaos/fuzz.go b/plugin/chaos/fuzz.go index df2e9a0dd..53667f2cd 100644 --- a/plugin/chaos/fuzz.go +++ b/plugin/chaos/fuzz.go @@ -9,5 +9,5 @@ import ( // Fuzz fuzzes cache. func Fuzz(data []byte) int { c := Chaos{} - return fuzz.Do(c, nil, data) + return fuzz.Do(c, data) } diff --git a/plugin/file/fuzz.go b/plugin/file/fuzz.go index de26ccc8a..e693f58bf 100644 --- a/plugin/file/fuzz.go +++ b/plugin/file/fuzz.go @@ -15,7 +15,7 @@ func Fuzz(data []byte) int { zone, _ := Parse(strings.NewReader(fuzzMiekNL), name, "stdin", 0) f := File{Next: test.ErrorHandler(), Zones: Zones{Z: map[string]*Zone{name: zone}, Names: []string{name}}} - return fuzz.Do(f, nil, data) + return fuzz.Do(f, data) } const fuzzMiekNL = ` diff --git a/plugin/pkg/fuzz/do.go b/plugin/pkg/fuzz/do.go index 95a5400f1..054c4298a 100644 --- a/plugin/pkg/fuzz/do.go +++ b/plugin/pkg/fuzz/do.go @@ -11,12 +11,7 @@ import ( ) // Do will fuzz p - used by gofuzz. See Makefile.fuzz for comments and context. -func Do(p plugin.Handler, fn SetupFunc, data []byte) int { - if fn != nil { - if err := fn(); err != nil { - panic("fuzz: " + err.Error()) - } - } +func Do(p plugin.Handler, data []byte) int { ctx := context.TODO() r := new(dns.Msg) if err := r.Unpack(data); err != nil { diff --git a/plugin/pkg/fuzz/setup.go b/plugin/pkg/fuzz/setup.go deleted file mode 100644 index 7c44b0ef3..000000000 --- a/plugin/pkg/fuzz/setup.go +++ /dev/null @@ -1,10 +0,0 @@ -package fuzz - -// SetupFunc can be given to Do to perform a one time setup of the fuzzing -// environment. This function is called on every fuzz, it is your -// responsibility to make it idempotent. If SetupFunc returns an error, panic -// is called with that error. -// -// There isn't a ShutdownFunc, because fuzzing is supposed to be run for a long -// time and there isn't any hook to call it from. -type SetupFunc func() error diff --git a/plugin/rewrite/fuzz.go b/plugin/rewrite/fuzz.go index e096db535..757ffab45 100644 --- a/plugin/rewrite/fuzz.go +++ b/plugin/rewrite/fuzz.go @@ -17,5 +17,5 @@ func Fuzz(data []byte) int { } r := Rewrite{Rules: rules} - return fuzz.Do(r, nil, data) + return fuzz.Do(r, data) } diff --git a/plugin/whoami/fuzz.go b/plugin/whoami/fuzz.go index 3d790ab63..70f2bd602 100644 --- a/plugin/whoami/fuzz.go +++ b/plugin/whoami/fuzz.go @@ -9,5 +9,5 @@ import ( // Fuzz fuzzes cache. func Fuzz(data []byte) int { w := Whoami{} - return fuzz.Do(w, nil, data) + return fuzz.Do(w, data) }