network: check compressed payload size in decompress
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
13999252c6
commit
34b1b52784
3 changed files with 36 additions and 0 deletions
26
pkg/network/fuzz_test.go
Normal file
26
pkg/network/fuzz_test.go
Normal file
|
@ -0,0 +1,26 @@
|
|||
//go:build go1.18
|
||||
// +build go1.18
|
||||
|
||||
package network
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
"testing"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/io"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func FuzzMessageDecode(f *testing.F) {
|
||||
for i := 0; i < 100; i++ {
|
||||
seed := make([]byte, rand.Uint32()%1000)
|
||||
rand.Read(seed)
|
||||
f.Add(seed)
|
||||
}
|
||||
|
||||
f.Fuzz(func(t *testing.T, value []byte) {
|
||||
m := new(Message)
|
||||
r := io.NewBinReaderFromBuf(value)
|
||||
require.NotPanics(t, func() { _ = m.Decode(r) })
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue