forked from godbus/dbus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add fuzz test for (signature) decoding
- Loading branch information
Showing
2 changed files
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
//go:build go1.18 | ||
// +build go1.18 | ||
|
||
package dbus | ||
|
||
import ( | ||
"bytes" | ||
"encoding/binary" | ||
"testing" | ||
) | ||
|
||
func FuzzProto(f *testing.F) { | ||
for _, t := range protoTests { | ||
f.Add(t.bigEndian, SignatureOf(t.vs...).str) | ||
f.Add(t.littleEndian, SignatureOf(t.vs...).str) | ||
} | ||
f.Fuzz(func(t *testing.T, buf []byte, sigStr string) { | ||
sig, err := ParseSignature(sigStr) | ||
if err != nil { | ||
return | ||
} | ||
bigDec := newDecoder(bytes.NewReader(buf), binary.BigEndian, make([]int, 0)) | ||
_, _ = bigDec.Decode(sig) | ||
}) | ||
} |
3 changes: 3 additions & 0 deletions
3
testdata/fuzz/FuzzProto/55fb6653b98fd09c839000a246acaabd9bd977bd526d7bb79ff949d848716fb6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
go test fuzz v1 | ||
[]byte("0") | ||
string("a{}") |