From: Matt Corallo Date: Wed, 18 Jul 2018 17:36:00 +0000 (-0400) Subject: Fix channelmonitor fuzz test failure X-Git-Tag: v0.0.12~391^2 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=4f644f225c059e2731d848077adac11edb9cdcca;p=rust-lightning Fix channelmonitor fuzz test failure --- diff --git a/src/ln/channelmonitor.rs b/src/ln/channelmonitor.rs index d212a3fdb..8c3fcc3f0 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)));