add fuzzing driver and crashes found with it

This commit is contained in:
Krzysztof Kowalczyk 2018-01-30 22:32:13 -08:00
parent 373bb10556
commit 339c59ffbe
2 changed files with 36 additions and 0 deletions

9
fuzz.go Normal file
View File

@ -0,0 +1,9 @@
// +build gofuzz
package markdown
// Fuzz is to be used by https://github.com/dvyukov/go-fuzz
func Fuzz(data []byte) int {
Parse(data, nil)
return 0
}

27
fuzz_crashes_test.go Normal file
View File

@ -0,0 +1,27 @@
package markdown
import "testing"
// crashes found with go-fuzz
func TestCrash1(t *testing.T) {
tests := []string{
": \n\n0\n00",
">>>0```\n\n:\n```",
">0```\n: \n\n0\n```",
">>>>0```\n\n:\n```",
"0\n\n:\n00",
">>0```\n\n:\n```",
"[0]:<",
"[[[[[[\n\t: ]]]]]]\n\n: " + "\n\n:(()",
">0\n>\n:\n00",
": : \n\n\t0\n00",
"0\n: : \n\n\t0\n00",
"0\n\n:\n00",
"0\n\n: [0]:<",
"[0]:<",
}
for _, test := range tests {
Parse([]byte(test), nil)
}
}