Add CC0 COPYING file.
[dnstt.git] / dns / fuzz.go
blobab4365c2631340756220db271aac5f64664ad475
1 //go:build gofuzz
2 // +build gofuzz
4 // Fuzzing driver for https://github.com/dvyukov/go-fuzz.
5 // go get -u github.com/dvyukov/go-fuzz/go-fuzz github.com/dvyukov/go-fuzz/go-fuzz-build
6 // $GOPATH/bin/go-fuzz-build
7 // $GOPATH/bin/go-fuzz
8 //
9 // Related link: https://blog.cloudflare.com/dns-parser-meet-go-fuzzer/
11 package dns
13 func Fuzz(data []byte) int {
14 msg, err := MessageFromWireFormat(data)
15 if err != nil {
16 return 0
18 _, err = msg.WireFormat()
19 if err != nil {
20 panic(err)
22 return 1 // prioritize this input