2024-10-17 20:09:39 +00:00
|
|
|
//go:build fuzz
|
2018-05-01 23:45:06 +00:00
|
|
|
// +build fuzz
|
|
|
|
|
|
|
|
package dns
|
|
|
|
|
2020-02-21 15:53:11 +00:00
|
|
|
import "strings"
|
|
|
|
|
2018-05-01 23:45:06 +00:00
|
|
|
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 {
|
2020-02-21 15:53:11 +00:00
|
|
|
str := string(data)
|
|
|
|
// Do not fuzz lines that include the $INCLUDE keyword and hint the fuzzer
|
|
|
|
// at avoiding them.
|
|
|
|
// See GH#1025 for context.
|
|
|
|
if strings.Contains(strings.ToUpper(str), "$INCLUDE") {
|
|
|
|
return -1
|
|
|
|
}
|
|
|
|
if _, err := NewRR(str); err != nil {
|
2018-05-01 23:45:06 +00:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
return 1
|
|
|
|
}
|