Skip to content

Commit

Permalink
fix(types): Implement nil check on commit.ValidateBasic (celestiaorg#…
Browse files Browse the repository at this point in the history
…1094)

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 and evan-forbes committed Sep 28, 2023
1 parent 36c53b8 commit e67de45
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 e67de45

Please sign in to comment.