Skip to content

Commit

Permalink
add byte len check
Browse files Browse the repository at this point in the history
  • Loading branch information
kz committed May 17, 2020
1 parent 6a99085 commit 2e16cf2
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ impl Rlp {
}
} else if hdr <= 0xbf {
let len_bytes_len = hdr as usize - 0xb7; // range of len_bytes_len is 1 to 8
if len_bytes_len > 8 {
return Err(SerErr::LengthTooLarge(len_bytes_len as u8, st.get_index())); // TODO write test
}
match st.take(len_bytes_len) {
Fail(index) => return Err(SerErr::NoLengthSize(len_bytes_len, index)),
Bytes(len_bytes) => {
Expand Down

0 comments on commit 2e16cf2

Please sign in to comment.