From 4f644f225c059e2731d848077adac11edb9cdcca Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Wed, 18 Jul 2018 13:36:00 -0400 Subject: [PATCH] Fix channelmonitor fuzz test failure --- src/ln/channelmonitor.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/ln/channelmonitor.rs b/src/ln/channelmonitor.rs index d212a3fd..8c3fcc3f 100644 --- a/src/ln/channelmonitor.rs +++ b/src/ln/channelmonitor.rs @@ -770,7 +770,14 @@ impl ChannelMonitor { () => { { let tx_len = byte_utils::slice_to_be64(read_bytes!(8)); - let tx: Transaction = unwrap_obj!(serialize::deserialize(read_bytes!(tx_len))); + let tx_ser = read_bytes!(tx_len); + let tx: Transaction = unwrap_obj!(serialize::deserialize(tx_ser)); + if serialize::serialize(&tx).unwrap() != tx_ser { + // We check that the tx re-serializes to the same form to ensure there is + // no extra data, and as rust-bitcoin doesn't handle the 0-input ambiguity + // all that well. + return None; + } let revocation_key = unwrap_obj!(PublicKey::from_slice(&secp_ctx, read_bytes!(33))); let a_htlc_key = unwrap_obj!(PublicKey::from_slice(&secp_ctx, read_bytes!(33))); -- 2.30.2