Skip to content

Commit e8edbe1

Browse files
committed
elf: add go-fuzz target
As with the BTF fuzz target, add a function that tests ELF loading.
1 parent 31d22a7 commit e8edbe1

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

elf_reader_fuzz.go

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// +build gofuzz
2+
3+
// Use with https://github.com/dvyukov/go-fuzz
4+
5+
package ebpf
6+
7+
import "bytes"
8+
9+
func FuzzLoadCollectionSpec(data []byte) int {
10+
spec, err := LoadCollectionSpecFromReader(bytes.NewReader(data))
11+
if err != nil {
12+
if spec != nil {
13+
panic("spec is not nil")
14+
}
15+
return 0
16+
}
17+
if spec == nil {
18+
panic("spec is nil")
19+
}
20+
return 1
21+
}

0 commit comments

Comments
 (0)