Skip to content

Commit

Permalink
fix(TypedTransaction::decode): do not panic on bad rlp input
Browse files Browse the repository at this point in the history
  • Loading branch information
emostov committed Dec 5, 2023
1 parent 11425f6 commit 1975cfd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ethers-core/src/types/transaction/eip2718.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ impl TypedTransaction {
impl Decodable for TypedTransaction {
fn decode(rlp: &rlp::Rlp) -> Result<Self, rlp::DecoderError> {
let tx_type: Option<U64> = match rlp.is_data() {
true => Some(rlp.data()?.into()),
true => Some(U64::decode(rlp)?),
false => None,
};
let rest = rlp::Rlp::new(
Expand Down Expand Up @@ -915,6 +915,6 @@ mod tests {
let tx = hex::decode("b9011e02f9011a0180850ba43b7400850df8475864830493e0947a250d5630b4cf539739df2c5dacb4c659f2488d88016345785d8a0000b8e4b6f9de95000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000005bd929b84c3dac16515c6b6c95f70fdae9c05c0c00000000000000000000000000000000000000000000000000000000650267140000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec7c0808080").unwrap();
let tx_rlp = rlp::Rlp::new(&tx);
let result = TypedTransaction::decode(&tx_rlp);
assert!(result.is_err());
assert_eq!(result.unwrap_err(), rlp::DecoderError::RlpIsTooBig);
}
}

0 comments on commit 1975cfd

Please sign in to comment.