mirror of
https://github.com/miekg/dns.git
synced 2025-08-11 03:56:58 +02:00
Add easy way to fuzz this dns library, put fuzz related code in fuzz.go and have a small Makefile.fuzz to be used: $ make -f Makefile.fuzz build $ make -f Makefile.fuzz fuzz Will build and fuzz the library. Both pack/unpack and NewRR are fuzz targets, but we could open this up.
24 lines
307 B
Go
24 lines
307 B
Go
// +build fuzz
|
|
|
|
package dns
|
|
|
|
func Fuzz(data []byte) int {
|
|
msg := new(Msg)
|
|
|
|
if err := msg.Unpack(data); err != nil {
|
|
return 0
|
|
}
|
|
if _, err := msg.Pack(); err != nil {
|
|
return 0
|
|
}
|
|
|
|
return 1
|
|
}
|
|
|
|
func FuzzNewRR(data []byte) int {
|
|
if _, err := NewRR(string(data)); err != nil {
|
|
return 0
|
|
}
|
|
return 1
|
|
}
|