From: Duncan Dean Date: Tue, 9 May 2023 06:37:58 +0000 (+0200) Subject: Enforce that no bytes remain for TransactionU16LenLimited read X-Git-Tag: v0.0.116-alpha1~43^2 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=33e901a88f43fd6426b14b934fcdd15d5f6bc04e;p=rust-lightning Enforce that no bytes remain for TransactionU16LenLimited read --- diff --git a/lightning/src/util/ser.rs b/lightning/src/util/ser.rs index 1570e5aee..cbdb5485e 100644 --- a/lightning/src/util/ser.rs +++ b/lightning/src/util/ser.rs @@ -1384,7 +1384,12 @@ impl Readable for TransactionU16LenLimited { fn read(r: &mut R) -> Result { let len = ::read(r)?; let mut tx_reader = FixedLengthReader::new(r, len as u64); - Ok(Self(Readable::read(&mut tx_reader)?)) + let tx: Transaction = Readable::read(&mut tx_reader)?; + if tx_reader.bytes_remain() { + Err(DecodeError::BadLengthDescriptor) + } else { + Ok(Self(tx)) + } } }