From 9f42108ef22d7100f21a0de3facbc9b760807b39 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Fri, 19 Jun 2020 11:18:43 +0300 Subject: [PATCH] network: allow NullPayload only for specific commands CMDFilterClear, CMDGetAddr, CMDMempool all have empty payloads. --- pkg/network/message.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/network/message.go b/pkg/network/message.go index a4eeea882..12674698a 100644 --- a/pkg/network/message.go +++ b/pkg/network/message.go @@ -106,7 +106,12 @@ func (m *Message) Decode(br *io.BinReader) error { // check the length first in order not to allocate memory // for an empty compressed payload if l == 0 { - m.Payload = payload.NewNullPayload() + switch m.Command { + case CMDFilterClear, CMDGetAddr, CMDMempool: + m.Payload = payload.NewNullPayload() + default: + return errors.New("unexpected empty payload") + } return nil } if l > PayloadMaxSize {