bugfix: guard against nil message.View before calling IsValidValidator in isAcceptableMessage#100
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses a potential nil-pointer dereference in the IBFT message validation path by ensuring malformed messages (nil message / nil message.View) are rejected before backend validator checks run.
Changes:
- Reorders
isAcceptableMessagechecks to guard againstnilmessage/message.Viewbefore callingbackend.IsValidValidator. - Refactors
RunSequenceby extracting per-round logic into a newrunRoundhelper. - Updates GolangCI linter configuration by removing the
exportloopreflinter.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| core/ibft.go | Adds nil guards in isAcceptableMessage; refactors RunSequence into runRound |
| .golangci.yml | Removes exportloopref from enabled linters |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.



Description
Previously,
isAcceptableMessagecalledi.backend.IsValidValidator(message)before checking whether message ormessage.Viewwere nil. This meant that if a message with a nilViewwas received, it could be passed intoIsValidValidator, potentially causing a nil pointer dereference inside the backend implementation.This fix reorders the checks so that the nil guards for message and message.
Vieware evaluated first, ensuringIsValidValidatoris only called with a well-formed message.This PR also refactors
RunSequenceby extractingrunRound. This is done becauseSonarandlinterbecause they requireddefer cancelRound()afterctxRound, cancelRound := context.WithCancel(ctx)Unsupported
exportlooprefextension has been removed fromGolangCIlinter configurationChanges include
Breaking changes
Please complete this section if any breaking changes have been made, otherwise delete it
Checklist
Additional comments
Please post additional comments in this section if you have them, otherwise delete it