fuzzy
fuzzy copied to clipboard
Fuzzing Fuzzy project
This adds a fuzz target and quickly fixes a first bug found by it
Reproducer for the bug is https://play.golang.org/p/ahd0SUU1J76
package main
import (
"fmt"
"github.com/sahilm/fuzzy"
)
func main() {
pattern := "\n\x13b\x00b\x98ш\x88\x95"
datas := []string{"\bL\x05\x00\x00\x00\xef\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x98ш\x88D\x95\x95\xbc\x15\xff\x03\x95\xd6\b%%\nB\n\x00\x00\xef\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x98ш\b\b"}
matches := fuzzy.Find(pattern, datas)
fmt.Printf("Hello, playground %#+v", matches)
}
outputs
panic: runtime error: index out of range [9] with length 9
goroutine 1 [running]:
github.com/sahilm/fuzzy.FindFrom(0x116e83, 0xa, 0x15e960, 0x40a0e0, 0x40a0e0, 0x1793, 0x430070, 0x1)
/tmp/gopath192064974/pkg/mod/github.com/sahilm/[email protected]/fuzzy.go:116 +0xbe0