1
0
Fork 1
mirror of https://github.com/vbatts/tar-split.git synced 2025-02-17 23:07:51 +00:00

tar/asm: try out a go-fuzz test

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
Vincent Batts 2017-04-11 09:32:07 -04:00
parent 4de2011f4a
commit 8c5af0ccf2
Signed by: vbatts
GPG key ID: 10937E57733F1362

38
tar/asm/fuzz.go Normal file
View file

@ -0,0 +1,38 @@
// +build gofuzz
package asm
import (
"bytes"
"log"
"github.com/vbatts/tar-split/archive/tar"
"github.com/vbatts/tar-split/tar/storage"
)
func Fuzz(data []byte) int {
sp := storage.NewJSONPacker(bytes.NewBuffer([]byte{}))
fgp := storage.NewBufferFileGetPutter()
tarStream, err := NewInputTarStream(bytes.NewReader(data), sp, fgp)
if err != nil {
if tarStream != nil {
panic("tarStream is != nil on error")
}
log.Println(err)
return 0
}
rdr := tar.NewReader(tarStream)
for {
hdr, err := rdr.Next()
if err != nil {
if hdr != nil {
panic("hdr is != nil on error")
}
log.Println(err)
return 0
}
log.Printf("%v", hdr)
}
return 1
}