From 3fed06989a4421b37ffc4d56497579505973f742 Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Mon, 15 Feb 2021 15:19:05 +0300 Subject: [PATCH] network: allow larger extensible payload --- pkg/network/payload/extensible.go | 2 +- pkg/network/payload/extensible_test.go | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/pkg/network/payload/extensible.go b/pkg/network/payload/extensible.go index 838d519ac..d894d7712 100644 --- a/pkg/network/payload/extensible.go +++ b/pkg/network/payload/extensible.go @@ -65,7 +65,7 @@ func (e *Extensible) decodeBinaryUnsigned(r *io.BinReader) { e.ValidBlockStart = r.ReadU32LE() e.ValidBlockEnd = r.ReadU32LE() r.ReadBytes(e.Sender[:]) - e.Data = r.ReadVarBytes(maxExtensibleDataSize) + e.Data = r.ReadVarBytes(MaxSize) } // DecodeBinary implements io.Serializable. diff --git a/pkg/network/payload/extensible_test.go b/pkg/network/payload/extensible_test.go index 846ed676c..88ae45189 100644 --- a/pkg/network/payload/extensible_test.go +++ b/pkg/network/payload/extensible_test.go @@ -41,6 +41,14 @@ func TestExtensible_Serializable(t *testing.T) { err := testserdes.DecodeBinary(append(unsigned, 42), new(Extensible)) require.True(t, errors.Is(err, errInvalidPadding)) }) + t.Run("too large data size", func(t *testing.T) { + expected.Data = make([]byte, MaxSize+1) + w := io.NewBufBinWriter() + expected.encodeBinaryUnsigned(w.BinWriter) + unsigned = w.Bytes() + err := testserdes.DecodeBinary(unsigned, new(Extensible)) + require.NotNil(t, err) + }) }) }