Skip to content

Commit

Permalink
fix: pass slice to RlpReceipt::rlp_decode_fields
Browse files Browse the repository at this point in the history
  • Loading branch information
klkvr committed Nov 27, 2024
1 parent 0ca76e8 commit 7a158f7
Showing 1 changed file with 7 additions and 5 deletions.
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

0 comments on commit 7a158f7

Please sign in to comment.