Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit ee0a9f1

Browse files
committed
Added verification of length in decodeLazyList
1 parent 748690a commit ee0a9f1

File tree

1 file changed

+4
-0
lines changed
  • ethereumj-core/src/main/java/org/ethereum/util

1 file changed

+4
-0
lines changed

ethereumj-core/src/main/java/org/ethereum/util/RLP.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,8 @@ public static LList decodeLazyList(byte[] data, int pos, int length) {
820820
} else if (prefix < OFFSET_SHORT_LIST) { // [0xb8, 0xbf]
821821
int lenlen = prefix - OFFSET_LONG_ITEM; // length of length the encoded bytes
822822
int lenbytes = byteArrayToInt(copyOfRange(data, pos + 1, pos + 1 + lenlen)); // length of encoded bytes
823+
// check that length is in payload bounds
824+
verifyLength(lenbytes, data.length - pos - 1 - lenlen);
823825
ret.add(pos + 1 + lenlen, lenbytes, false);
824826
pos += 1 + lenlen + lenbytes;
825827
} else if (prefix <= OFFSET_LONG_LIST) { // [0xc0, 0xf7]
@@ -829,6 +831,8 @@ public static LList decodeLazyList(byte[] data, int pos, int length) {
829831
} else if (prefix <= 0xFF) { // [0xf8, 0xff]
830832
int lenlen = prefix - OFFSET_LONG_LIST; // length of length the encoded list
831833
int lenlist = byteArrayToInt(copyOfRange(data, pos + 1, pos + 1 + lenlen)); // length of encoded bytes
834+
// check that length is in payload bounds
835+
verifyLength(lenlist, data.length - pos - 1 - lenlen);
832836
ret.add(pos + 1 + lenlen, lenlist, true);
833837
pos += 1 + lenlen + lenlist; // start at position of first element in list
834838
} else {

0 commit comments

Comments
 (0)