Skip to content

Commit

Permalink
fix(types): Implement nil check on commit.ValidateBasic (#1094)
Browse files Browse the repository at this point in the history
Found in celestia-node header validation check. If a malformed
`ExtendedHeader` with a nil Commit is broadcasted through the network,
it would cause recipients to panic. We decided the check belongs in core
as ValidatorSet also does a nil check.
  • Loading branch information
renaynay authored Sep 25, 2023
1 parent 322710f commit 13b9e92
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions types/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,10 @@ func (commit *Commit) IsCommit() bool {
// ValidateBasic performs basic validation that doesn't involve state data.
// Does not actually check the cryptographic signatures.
func (commit *Commit) ValidateBasic() error {
if commit == nil {
return errors.New("nil commit")
}

if commit.Height < 0 {
return errors.New("negative Height")
}
Expand Down

0 comments on commit 13b9e92

Please sign in to comment.