From 35280f5faa1454fecd17e88125cf027911bf2a19 Mon Sep 17 00:00:00 2001 From: sardChen Date: Wed, 11 Aug 2021 22:35:09 +0800 Subject: [PATCH] Fix FAB-18528: remove panic in ifConfig func Fix issues: FAB-18528. When received the constructed message from the malicious node (through the interface "chain.rpc.SendSubmit(dest uint64, request *orderer.SubmitRequest, report func(err error))"), all orderers will breakdown immediately. Signed-off-by: sardChen --- orderer/consensus/etcdraft/chain.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/orderer/consensus/etcdraft/chain.go b/orderer/consensus/etcdraft/chain.go index 240e784e857..7894f9af735 100644 --- a/orderer/consensus/etcdraft/chain.go +++ b/orderer/consensus/etcdraft/chain.go @@ -891,7 +891,12 @@ func (c *Chain) writeBlock(block *common.Block, index uint64) { func (c *Chain) ordered(msg *orderer.SubmitRequest) (batches [][]*common.Envelope, pending bool, err error) { seq := c.support.Sequence() - if c.isConfig(msg.Payload) { + isconfig, err := c.isConfig(msg.Payload) + if err != nil { + return nil, false, errors.Errorf("bad message: %s", err) + } + + if isconfig { // ConfigMsg if msg.LastValidationSeq < seq { c.logger.Warnf("Config message was validated against %d, although current config seq has advanced (%d)", msg.LastValidationSeq, seq) @@ -1163,13 +1168,14 @@ func (c *Chain) gc() { } } -func (c *Chain) isConfig(env *common.Envelope) bool { +func (c *Chain) isConfig(env *common.Envelope) (bool, error) { h, err := protoutil.ChannelHeader(env) if err != nil { - c.logger.Panicf("failed to extract channel header from envelope") + c.logger.Errorf("failed to extract channel header from envelope") + return false, err } - return h.Type == int32(common.HeaderType_CONFIG) || h.Type == int32(common.HeaderType_ORDERER_TRANSACTION) + return h.Type == int32(common.HeaderType_CONFIG) || h.Type == int32(common.HeaderType_ORDERER_TRANSACTION), nil } func (c *Chain) configureComm() error {