forked from itchio/boar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfuzz.go
More file actions
49 lines (38 loc) · 720 Bytes
/
fuzz.go
File metadata and controls
49 lines (38 loc) · 720 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//+build gofuzz
package boar
import (
"fmt"
"io"
"github.com/itchio/boar/memfs"
"github.com/itchio/savior"
"github.com/itchio/headway/state"
)
var _dummyConsumer = &state.Consumer{
OnMessage: func(lvl string, message string) {
fmt.Printf("[%s] %s", lvl, message)
},
}
func Fuzz(data []byte) int {
file := memfs.New(data, "data")
params := ProbeParams{
File: file,
Consumer: _dummyConsumer,
}
info, err := Probe(params)
if err != nil {
return 0
}
_, err = file.Seek(0, io.SeekStart)
if err != nil {
return 0
}
ex, err := info.GetExtractor(file, _dummyConsumer)
if err != nil {
return 0
}
_, err = ex.Resume(nil, &savior.NopSink{})
if err != nil {
return 0
}
return 1
}