Skip to content

Commit

Permalink
Harden NetworkProcessNet.go by detecting message that get a nil hash …
Browse files Browse the repository at this point in the history
…and tossing them.
  • Loading branch information
factom-clay committed Jun 15, 2018
1 parent 395a318 commit 59450c0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion engine/NetworkProcessorNet.go
Expand Up @@ -130,6 +130,11 @@ func Peers(fnode *FactomNode) {
if msg == nil {
continue
}
if msg.GetHash() == nil {
fnode.State.LogMessage("badMsgs", "Nil hash from APIQueue", msg)
continue
}

// TODO: Is this as intended for 'x' command? -- clay
if fnode.State.GetNetStateOff() { // drop received message if he is off
fnode.State.LogMessage("NetworkInputs", "API drop, X'd by simCtrl", msg)
Expand Down Expand Up @@ -201,7 +206,6 @@ func Peers(fnode *FactomNode) {
// Receive is not blocking; nothing to do, we get a nil.
break // move to next peer
}

if err != nil {
fnode.State.LogPrintf("NetworkInputs", "error on receive from %v: %v", peer.GetNameFrom(), err)
fmt.Println("ERROR receiving message on", fnode.State.FactomNodeName+":", err)
Expand All @@ -218,6 +222,11 @@ func Peers(fnode *FactomNode) {
fnode.State.TallyReceived(int(msg.Type())) //TODO: Do we want to count dropped message?
}

if msg.GetHash() == nil {
fnode.State.LogMessage("badMsgs", "Nil hash from Peer", msg)
continue
}

if fnode.State.GetNetStateOff() { // drop received message if he is off
fnode.State.LogMessage("NetworkInputs", fromPeer+" Drop, X'd by simCtrl", msg)
continue // Toss any inputs from this peer
Expand Down
2 changes: 1 addition & 1 deletion state/stateConsensus.go
Expand Up @@ -70,7 +70,7 @@ func (s *State) LogPrintf(logName string, format string, more ...interface{}) {
func (s *State) executeMsg(vm *VM, msg interfaces.IMsg) (ret bool) {

if msg.GetHash() == nil {
s.LogMessage("badMsgs", "Nil hash", msg)
s.LogMessage("badMsgs", "Nil hash in executeMsg", msg)
return false
}

Expand Down

0 comments on commit 59450c0

Please sign in to comment.