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 and cmwaters committed Sep 28, 2023
1 parent 36c53b8 commit cff36f5
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 cff36f5

Please sign in to comment.