gtsocial-umbx

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

fuzz.go (552B)


      1 //go:build fuzz
      2 // +build fuzz
      3 
      4 package dns
      5 
      6 import "strings"
      7 
      8 func Fuzz(data []byte) int {
      9 	msg := new(Msg)
     10 
     11 	if err := msg.Unpack(data); err != nil {
     12 		return 0
     13 	}
     14 	if _, err := msg.Pack(); err != nil {
     15 		return 0
     16 	}
     17 
     18 	return 1
     19 }
     20 
     21 func FuzzNewRR(data []byte) int {
     22 	str := string(data)
     23 	// Do not fuzz lines that include the $INCLUDE keyword and hint the fuzzer
     24 	// at avoiding them.
     25 	// See GH#1025 for context.
     26 	if strings.Contains(strings.ToUpper(str), "$INCLUDE") {
     27 		return -1
     28 	}
     29 	if _, err := NewRR(str); err != nil {
     30 		return 0
     31 	}
     32 	return 1
     33 }