Skip to content

Commit

Permalink
fix: DecodeRLP can panic
Browse files Browse the repository at this point in the history
  • Loading branch information
simlecode committed Aug 23, 2023
1 parent 3ad5dc8 commit 0e1e1af
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions venus-shared/actors/types/rlp.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ func decodeLength(data []byte, lenInBytes int) (length int, err error) {
if err := binary.Read(r, binary.BigEndian, &decodedLength); err != nil {
return 0, fmt.Errorf("invalid rlp data: cannot parse string length: %w", err)
}
if decodedLength < 0 {
return 0, fmt.Errorf("invalid rlp data: negative string length")
}

totalLength := lenInBytes + int(decodedLength)
if totalLength < 0 || totalLength > len(data) {
Expand Down

0 comments on commit 0e1e1af

Please sign in to comment.