rejecting malformed messages before processing (#2776)

handling malformed messages locally

minor
pull/2783/head
Ganesha Upadhyaya 5 years ago committed by GitHub
parent a1c8156afc
commit 7178eabbf1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      consensus/checks.go

@ -11,6 +11,10 @@ import (
const MaxBlockNumDiff = 100 const MaxBlockNumDiff = 100
func (consensus *Consensus) validatorSanityChecks(msg *msg_pb.Message) bool { func (consensus *Consensus) validatorSanityChecks(msg *msg_pb.Message) bool {
if msg.GetConsensus() == nil {
consensus.getLogger().Warn().Msg("[validatorSanityChecks] malformed message")
return false
}
consensus.getLogger().Debug(). consensus.getLogger().Debug().
Uint64("blockNum", msg.GetConsensus().BlockNum). Uint64("blockNum", msg.GetConsensus().BlockNum).
Uint64("viewID", msg.GetConsensus().ViewId). Uint64("viewID", msg.GetConsensus().ViewId).
@ -47,6 +51,10 @@ func (consensus *Consensus) validatorSanityChecks(msg *msg_pb.Message) bool {
} }
func (consensus *Consensus) leaderSanityChecks(msg *msg_pb.Message) bool { func (consensus *Consensus) leaderSanityChecks(msg *msg_pb.Message) bool {
if msg.GetConsensus() == nil {
consensus.getLogger().Warn().Msg("[leaderSanityChecks] malformed message")
return false
}
consensus.getLogger().Debug(). consensus.getLogger().Debug().
Uint64("blockNum", msg.GetConsensus().BlockNum). Uint64("blockNum", msg.GetConsensus().BlockNum).
Uint64("viewID", msg.GetConsensus().ViewId). Uint64("viewID", msg.GetConsensus().ViewId).
@ -180,6 +188,10 @@ func (consensus *Consensus) onPreparedSanityChecks(
} }
func (consensus *Consensus) viewChangeSanityCheck(msg *msg_pb.Message) bool { func (consensus *Consensus) viewChangeSanityCheck(msg *msg_pb.Message) bool {
if msg.GetViewchange() == nil {
consensus.getLogger().Warn().Msg("[viewChangeSanityCheck] malformed message")
return false
}
consensus.getLogger().Debug(). consensus.getLogger().Debug().
Msg("[viewChangeSanityCheck] Checking new message") Msg("[viewChangeSanityCheck] Checking new message")
senderKey, err := consensus.verifyViewChangeSenderKey(msg) senderKey, err := consensus.verifyViewChangeSenderKey(msg)

Loading…
Cancel
Save