aboutsummaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
authorGravatar Miek Gieben <miek@miek.nl> 2019-08-22 18:49:22 +0000
committerGravatar corbot[bot] <39114087+corbot[bot]@users.noreply.github.com> 2019-08-22 18:49:22 +0000
commit9f49d694e909651ceeb846a72269a28f55545f4f (patch)
tree35a0c52bc87868385af59962854a7eed88fb515b /plugin
parentf8e0ae63305ac712d8e40dfa72a6af497205f371 (diff)
downloadcoredns-9f49d694e909651ceeb846a72269a28f55545f4f.tar.gz
coredns-9f49d694e909651ceeb846a72269a28f55545f4f.tar.zst
coredns-9f49d694e909651ceeb846a72269a28f55545f4f.zip
fuzz: fix rewrite crash by fixing fuzz/do.go (#3178)
Automatically submitted.
Diffstat (limited to 'plugin')
-rw-r--r--plugin/pkg/fuzz/do.go12
1 files changed, 8 insertions, 4 deletions
diff --git a/plugin/pkg/fuzz/do.go b/plugin/pkg/fuzz/do.go
index e2bc0edee..054c4298a 100644
--- a/plugin/pkg/fuzz/do.go
+++ b/plugin/pkg/fuzz/do.go
@@ -13,15 +13,19 @@ import (
// Do will fuzz p - used by gofuzz. See Makefile.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
+ 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 {
- ret = 1
+ return 1
}
- return ret
+ return 0
}