From 33e901a88f43fd6426b14b934fcdd15d5f6bc04e Mon Sep 17 00:00:00 2001 From: Duncan Dean Date: Tue, 9 May 2023 08:37:58 +0200 Subject: [PATCH] Enforce that no bytes remain for TransactionU16LenLimited read --- lightning/src/util/ser.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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)) + } } } -- 2.39.5