Skip to content

Commit

Permalink
rlp decoder issue fixed for empty byte array
Browse files Browse the repository at this point in the history
  • Loading branch information
sagars committed Sep 6, 2024
1 parent d763a95 commit 1930344
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions libs/soroban-rlp/src/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,16 @@ pub fn decode_list(env: &Env, list: Bytes) -> Vec<Bytes> {
let data_bytes_len = (byte - 0xf7) as u64;
let len_bytes = slice_vector(&env, encoded.clone(), i as u64 + 1, data_bytes_len);
let len = bytes_to_u64(len_bytes);

decoded.push_back(slice_vector(
&env,
encoded.clone(),
i as u64,
data_bytes_len + len + 1,
));
if byte == 0xf8 && len == 0 {
decoded.push_back(Bytes::new(&env));
} else {
decoded.push_back(slice_vector(
&env,
encoded.clone(),
i as u64,
data_bytes_len + len + 1,
));
}
i = i + (data_bytes_len + len + 1) as u32
} else {
panic!("invalid rlp byte length")
Expand Down

0 comments on commit 1930344

Please sign in to comment.