network: allow larger extensible payload

This commit is contained in:
Anna Shaleva 2021-02-15 15:19:05 +03:00
parent 664a2a88eb
commit 3fed06989a
2 changed files with 9 additions and 1 deletions

View file

@ -65,7 +65,7 @@ func (e *Extensible) decodeBinaryUnsigned(r *io.BinReader) {
e.ValidBlockStart = r.ReadU32LE() e.ValidBlockStart = r.ReadU32LE()
e.ValidBlockEnd = r.ReadU32LE() e.ValidBlockEnd = r.ReadU32LE()
r.ReadBytes(e.Sender[:]) r.ReadBytes(e.Sender[:])
e.Data = r.ReadVarBytes(maxExtensibleDataSize) e.Data = r.ReadVarBytes(MaxSize)
} }
// DecodeBinary implements io.Serializable. // DecodeBinary implements io.Serializable.

View file

@ -41,6 +41,14 @@ func TestExtensible_Serializable(t *testing.T) {
err := testserdes.DecodeBinary(append(unsigned, 42), new(Extensible)) err := testserdes.DecodeBinary(append(unsigned, 42), new(Extensible))
require.True(t, errors.Is(err, errInvalidPadding)) 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)
})
}) })
} }