Skip to content

Commit

Permalink
Fix block: reject erroneous input
Browse files Browse the repository at this point in the history
  • Loading branch information
hijung committed Aug 4, 2023
1 parent c214863 commit e8e8729
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions icon/blockv0/blockvote.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,11 +329,19 @@ func (s *BlockVoteList) RLPDecodeSelf(d codec.Decoder) error {
if err != nil {
return err
}
for i, sh := range cbvl.Sharable {
if sh.Round == nil && sh.Round_ == nil {
return errors.Errorf("BlockVote with no round height=%d sharable index=%d", sh.BlockHeight, i)
}
}
s.votes = make([]*BlockVote, len(cbvl.Entries))
for i, e := range cbvl.Entries {
if e == nil {
s.votes[i] = nil
} else {
if len(cbvl.Sharable) <= int(e.SharableIndex) {
return errors.Errorf("invalid sharable index len(Sharable)=%d index=%d", len(cbvl.Sharable), e.SharableIndex)
}
s.votes[i] = &BlockVote{
BlockVoteJSON{
cbvl.Sharable[e.SharableIndex],
Expand Down

0 comments on commit e8e8729

Please sign in to comment.