You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When decoding bytes that have extra data, I would expect one of:
an error on decoding
a way to know the number of bytes that were readed, to externally deal with trailing data
example:
let input = vec![123,32,4,156,231,200];letmut stream = rlp::RlpStream::new();
input.rlp_append(&mut stream);let bytes = stream.out().freeze();letmut extra_data = bytes.to_vec();
extra_data.push(23);
extra_data.push(40);
rlp::decode::<Vec<u8>>(&extra_data).expect_err("extra data should not be ignored");
The text was updated successfully, but these errors were encountered:
divagant-martian
changed the title
rlp: trailling data is not rejected when decoding a list
rlp: handling extra data
Aug 3, 2023
rlp seems to accept concatenations of valid rlp data as valid rlp data, I think this is a bug.
Take for example [193, 75] this is a one element list with payload 75 [193, 75, 248] this as a whole is not valid rlp data. It's also not valid as concatenation of rlp data. This is not rejected [193, 75, 75] as a whole is also not valid rlp data.
However: [193, 75, 75] still produces item_count() = 2, and an iter that gives 75 and 75
Unsure if this a bug or an api shortcoming.
When decoding bytes that have extra data, I would expect one of:
example:
The text was updated successfully, but these errors were encountered: