network: fix "unexpected empty payload: CMDVersion"

We can have _a lot_ of these in the log, but the only reason they happen is
because we're trying to interpret length before checking for reader error,
CMDVersion is just 0.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
This commit is contained in:
Roman Khimov 2024-12-05 18:33:40 +03:00
parent 9a3923097b
commit 121307d349

View file

@ -99,6 +99,9 @@ func (m *Message) Decode(br *io.BinReader) error {
m.Flags = MessageFlag(br.ReadB())
m.Command = CommandType(br.ReadB())
l := br.ReadVarUint()
if br.Err != nil {
return br.Err
}
// check the length first in order not to allocate memory
// for an empty compressed payload
if l == 0 {