Skip to content

Commit

Permalink
[fuzzer] Avoid fuzzing parser with line that contains "$INCLUDE" (mie…
Browse files Browse the repository at this point in the history
…kg#1026)

Fixes miekg#1025

```
GO111MODULE=off make -f Makefile.fuzz build
go-fuzz -bin=dns-fuzz.zip -workdir=fuzz -func Fuzz
GO111MODULE=off make -f Makefile.fuzz build-rr
go-fuzz -bin=dns-fuzz.zip -workdir=fuzz -func FuzzNewRR
```
  • Loading branch information
chantra authored and aanm committed Jul 29, 2022
1 parent 6eeab4e commit 70dd9ec
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion fuzz.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

package dns

import "strings"

func Fuzz(data []byte) int {
msg := new(Msg)

Expand All @@ -16,7 +18,14 @@ func Fuzz(data []byte) int {
}

func FuzzNewRR(data []byte) int {
if _, err := NewRR(string(data)); err != nil {
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 {
return 0
}
return 1
Expand Down

0 comments on commit 70dd9ec

Please sign in to comment.