-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathfuzz_test.go
More file actions
49 lines (40 loc) · 843 Bytes
/
fuzz_test.go
File metadata and controls
49 lines (40 loc) · 843 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
// SPDX-FileCopyrightText: 2026 The Pion community <https://pion.ly>
// SPDX-License-Identifier: MIT
//go:build go1.18
package opus
import (
"bytes"
_ "embed"
"errors"
"io"
"testing"
"github.com/pion/opus/pkg/oggreader"
)
func FuzzDecoder(f *testing.F) {
f.Add([]byte{})
f.Add(tinyogg)
f.Fuzz(func(_ *testing.T, data []byte) {
var out [1920]byte
ogg, _, err := oggreader.NewWith(bytes.NewReader(data))
if err != nil {
return
}
decoder := NewDecoder()
for {
segments, _, err := ogg.ParseNextPage()
if errors.Is(err, io.EOF) {
break
} else if len(segments) > 0 && bytes.HasPrefix(segments[0], []byte("OpusTags")) {
continue
}
if err != nil {
return
}
for i := range segments {
if _, _, err = decoder.Decode(segments[i], out[:]); err != nil {
return
}
}
}
})
}