From 5a0f08f2c0ae33dc1f11e564a4895c2cde117223 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Sun, 22 Sep 2019 20:09:55 +0300 Subject: [PATCH] network: fix SIGSEGV on unknown message acceptance For example, at the moment our node can't handle `consensus` message, so when it received it before the patch it just crashed because of uninitialized `p`. --- pkg/network/message.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/network/message.go b/pkg/network/message.go index 1f702fc9f..187c7c9d9 100644 --- a/pkg/network/message.go +++ b/pkg/network/message.go @@ -3,6 +3,7 @@ package network import ( "encoding/binary" "errors" + "fmt" "github.com/CityOfZion/neo-go/config" "github.com/CityOfZion/neo-go/pkg/core" @@ -193,6 +194,8 @@ func (m *Message) decodePayload(br *io.BinReader) error { p = &transaction.Transaction{} case CMDMerkleBlock: p = &payload.MerkleBlock{} + default: + return fmt.Errorf("can't decode command %s", cmdByteArrayToString(m.Command)) } p.DecodeBinary(r) if r.Err != nil {