Skip to content

Commit

Permalink
fix: check integer overflow when decode crosschain payload (#1679)
Browse files Browse the repository at this point in the history
  • Loading branch information
yutianwu committed Jun 8, 2023
1 parent cf9efe5 commit 78ad049
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions core/vm/lightclient/v2/lightclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,11 @@ func DecodeLightBlockValidationInput(input []byte) (*ConsensusState, *types.Ligh
}

csLen := binary.BigEndian.Uint64(input[consensusStateLengthBytesLength-uint64TypeLength : consensusStateLengthBytesLength])

if consensusStateLengthBytesLength+csLen < consensusStateLengthBytesLength {
return nil, nil, fmt.Errorf("integer overflow, csLen: %d", csLen)
}

if uint64(len(input)) <= consensusStateLengthBytesLength+csLen {
return nil, nil, fmt.Errorf("expected payload size %d, actual size: %d", consensusStateLengthBytesLength+csLen, len(input))
}
Expand Down

0 comments on commit 78ad049

Please sign in to comment.