Skip to content

Commit

Permalink
[FAB-7725]: add nil checks for events processing
Browse files Browse the repository at this point in the history
The root cause behind of FAB-7725 is the fact that while dereferencing
certain fields after their desirialized, there is no proper check for
nil values, which might cause peer to crash once malstructured message
appears. This commit adds additional check as well as UT to cover the
issue described in FAB-7725.

Change-Id: I6b35aa6e62992a3e74e4b992d251675dc326f00f
Signed-off-by: Artem Barger <bartem@il.ibm.com>
  • Loading branch information
C0rWin committed Jan 17, 2018
1 parent a85b2fa commit 2c8a82a
Show file tree
Hide file tree
Showing 3 changed files with 267 additions and 111 deletions.
9 changes: 9 additions & 0 deletions core/peer/deliverevents.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,11 @@ func (block *blockEvent) toFilteredBlock() (*peer.FilteredBlock, error) {
return nil, errors.WithMessage(err, "could not extract payload from envelope")
}

if payload.Header == nil {
logger.Debugf("transaction payload header is nil, %d, block num %d",
txIndex, block.Header.Number)
continue
}
chdr, err := utils.UnmarshalChannelHeader(payload.Header.ChannelHeader)
if err != nil {
return nil, err
Expand Down Expand Up @@ -215,6 +220,10 @@ func (ta transactionActions) toFilteredActions() (*peer.FilteredTransaction_Tran
return nil, errors.WithMessage(err, "error unmarshal transaction action payload for block event")
}

if chaincodeActionPayload.Action == nil {
logger.Debugf("chaincode action, the payload action is nil, skipping")
continue
}
propRespPayload, err := utils.GetProposalResponsePayload(chaincodeActionPayload.Action.ProposalResponsePayload)
if err != nil {
return nil, errors.WithMessage(err, "error unmarshal proposal response payload for block event")
Expand Down
Loading

0 comments on commit 2c8a82a

Please sign in to comment.