Skip to content

bugfix: guard against nil message.View before calling IsValidValidator in isAcceptableMessage#100

Open
igorcrevar wants to merge 9 commits into0xPolygon:mainfrom
igorcrevar:bugfix/isAcceptableMessageFix
Open

bugfix: guard against nil message.View before calling IsValidValidator in isAcceptableMessage#100
igorcrevar wants to merge 9 commits into0xPolygon:mainfrom
igorcrevar:bugfix/isAcceptableMessageFix

Conversation

@igorcrevar
Copy link
Copy Markdown
Contributor

@igorcrevar igorcrevar commented Mar 9, 2026

Description

Previously, isAcceptableMessage called i.backend.IsValidValidator(message) before checking whether message or message.View were nil. This meant that if a message with a nil View was received, it could be passed into IsValidValidator, potentially causing a nil pointer dereference inside the backend implementation.

This fix reorders the checks so that the nil guards for message and message. View are evaluated first, ensuring IsValidValidator is only called with a well-formed message.

This PR also refactors RunSequence by extracting runRound. This is done because Sonar and linter because they required defer cancelRound() after ctxRound, cancelRound := context.WithCancel(ctx)

Unsupported exportloopref extension has been removed from GolangCI linter configuration

Changes include

  • Bugfix (non-breaking change that solves an issue)
  • Hotfix (change that solves an urgent issue, and requires immediate attention)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (change that is not backwards-compatible and/or changes current functionality)

Breaking changes

Please complete this section if any breaking changes have been made, otherwise delete it

Checklist

  • I have assigned this PR to myself
  • I have added at least 1 reviewer
  • I have added the relevant labels
  • I have added sufficient documentation in code

Additional comments

Please post additional comments in this section if you have them, otherwise delete it

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 isAcceptableMessage checks to guard against nil message / message.View before calling backend.IsValidValidator.
  • Refactors RunSequence by extracting per-round logic into a new runRound helper.
  • Updates GolangCI linter configuration by removing the exportloopref linter.

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.

Comment thread core/ibft.go Outdated
Comment thread core/ibft.go Outdated
Comment thread core/ibft.go Outdated
@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread core/ibft.go
Comment thread core/ibft.go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants