diff --git a/.gitignore b/.gitignore index 2f5ebc1..61cb813 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ -gh-pages/ +/gh-pages/ /go-org +/fuzz +/org-fuzz.zip \ No newline at end of file diff --git a/Makefile b/Makefile index c0b09f8..ccb8c14 100644 --- a/Makefile +++ b/Makefile @@ -32,3 +32,13 @@ generate-gh-pages: build .PHONY: generate-fixtures generate-fixtures: build ./etc/generate-fixtures + +.PHONY: fuzz +fuzz: build + @echo also see "http://lcamtuf.coredump.cx/afl/README.txt" + go get github.com/dvyukov/go-fuzz/go-fuzz + go get github.com/dvyukov/go-fuzz/go-fuzz-build + mkdir -p fuzz fuzz/corpus + cp org/testdata/*.org fuzz/corpus + go-fuzz-build github.com/niklasfasching/go-org/org + go-fuzz -bin=./org-fuzz.zip -workdir=fuzz diff --git a/org/fuzz.go b/org/fuzz.go new file mode 100644 index 0000000..8fad1dc --- /dev/null +++ b/org/fuzz.go @@ -0,0 +1,19 @@ +// +build gofuzz + +package org + +import "bytes" + +// Fuzz function to be used by https://github.com/dvyukov/go-fuzz +func Fuzz(data []byte) int { + d := NewDocument().Silent().Parse(bytes.NewReader(data)) + _, err := d.Write(NewOrgWriter()) + if err != nil { + panic(err) + } + _, err = d.Write(NewHTMLWriter()) + if err != nil { + panic(err) + } + return 0 +}