From 121307d34989db9e3c71a26d9b1f5721022edab9 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Thu, 5 Dec 2024 18:33:40 +0300 Subject: [PATCH] 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 --- pkg/network/message.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/network/message.go b/pkg/network/message.go index 2142d6a41..1f61879fe 100644 --- a/pkg/network/message.go +++ b/pkg/network/message.go @@ -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 {