Skip to content

Commit

Permalink
add fuzz test for (signature) decoding
Browse files Browse the repository at this point in the history
  • Loading branch information
guelfey committed Apr 15, 2022
1 parent 582a427 commit 3146f5b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
25 changes: 25 additions & 0 deletions proto_fuzz_test.go
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)
})
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
go test fuzz v1
[]byte("0")
string("a{}")

0 comments on commit 3146f5b

Please sign in to comment.