We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using rlp.decode_to_bytes(encoded_bytes=b'Q59:\xba\xf4\xda\x05\xb7') returns b'' because it silently slices the input data with a negative len
rlp.decode_to_bytes(encoded_bytes=b'Q59:\xba\xf4\xda\x05\xb7')
b''
def decode_to_bytes(encoded_bytes: Bytes) -> Bytes: """ Decodes a rlp encoded byte stream assuming that the decoded data should be of type `bytes`. Parameters ---------- encoded_bytes : RLP encoded byte stream. Returns ------- decoded : `ethereum.base_types.Bytes` RLP decoded Bytes data """ if len(encoded_bytes) == 1 and encoded_bytes[0] < 0x80: return encoded_bytes elif encoded_bytes[0] <= 0xB7: len_raw_data = encoded_bytes[0] - 0x80 ----> here len_raw_data = -47 if len_raw_data >= len(encoded_bytes): raise RLPDecodingError raw_data = encoded_bytes[1 : 1 + len_raw_data] if len_raw_data == 1 and raw_data[0] < 0x80: raise RLPDecodingError return raw_data
Some other examples
encoded_bytes=b'~\xbc\xc5^\xbe\xff'
len_raw_data = -2
I think that if len_raw_data >= len(encoded_bytes) should also check for negative lengths.
if len_raw_data >= len(encoded_bytes)
The text was updated successfully, but these errors were encountered:
ClementWalter
No branches or pull requests
Using
rlp.decode_to_bytes(encoded_bytes=b'Q59:\xba\xf4\xda\x05\xb7')
returnsb''
because it silently slices the input data with a negative lenSome other examples
encoded_bytes=b'~\xbc\xc5^\xbe\xff'
giveslen_raw_data = -2
and do return a bytesI think that
if len_raw_data >= len(encoded_bytes)
should also check for negative lengths.The text was updated successfully, but these errors were encountered: