Skip to content
New issue

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

fix: pass slice to RlpReceipt::rlp_decode_fields #1696

Merged
merged 2 commits into from
Nov 27, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions crates/consensus/src/receipt/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use alloy_primitives::Bloom;
use alloy_rlp::{BufMut, Header};
use alloy_rlp::{Buf, BufMut, Header};
use core::fmt;

mod envelope;
Expand Down Expand Up @@ -100,18 +100,20 @@ pub trait RlpReceipt: Sized {
if !header.list {
return Err(alloy_rlp::Error::UnexpectedString);
}
let remaining = buf.len();

if header.payload_length > remaining {
if header.payload_length > buf.len() {
return Err(alloy_rlp::Error::InputTooShort);
}

let this = Self::rlp_decode_fields_with_bloom(buf)?;
let mut fields_buf = &buf[..header.payload_length];
let this = Self::rlp_decode_fields_with_bloom(&mut fields_buf)?;

if buf.len() + header.payload_length != remaining {
if !fields_buf.is_empty() {
return Err(alloy_rlp::Error::UnexpectedLength);
}

buf.advance(header.payload_length);

Ok(this)
}
}
Expand Down
Loading