From cff36f5c15a1a2d19185fdbe97d15136bda9378d Mon Sep 17 00:00:00 2001 From: rene <41963722+renaynay@users.noreply.github.com> Date: Mon, 25 Sep 2023 23:50:12 +0200 Subject: [PATCH] fix(types): Implement nil check on commit.ValidateBasic (#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. --- types/block.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/types/block.go b/types/block.go index 662478b7c0..a7ea96c81a 100644 --- a/types/block.go +++ b/types/block.go @@ -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") }