Skip to content

Commit

Permalink
Fix FAB-18528: remove panic in ifConfig func (#2828)
Browse files Browse the repository at this point in the history
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 <sard.chen@gmail.com>
(cherry picked from commit 497a177)
  • Loading branch information
sardChen authored and ale-linux committed Feb 3, 2022
1 parent f7318ff commit 68b6b90
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions orderer/consensus/etcdraft/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,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)
Expand Down Expand Up @@ -1125,13 +1130,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 {
Expand Down

0 comments on commit 68b6b90

Please sign in to comment.