From: Matt Corallo Date: Mon, 23 Jul 2018 18:53:34 +0000 (-0400) Subject: Fix OOM crash in ChannelMonitor::deserialize found by AFL X-Git-Tag: v0.0.12~373^2 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=refs%2Fheads%2F2018-07-chanmon-oom;p=rust-lightning Fix OOM crash in ChannelMonitor::deserialize found by AFL --- diff --git a/src/ln/channelmonitor.rs b/src/ln/channelmonitor.rs index 2ee5b37a3..3fb1d8ad8 100644 --- a/src/ln/channelmonitor.rs +++ b/src/ln/channelmonitor.rs @@ -743,7 +743,7 @@ impl ChannelMonitor { for _ in 0..remote_claimable_outpoints_len { let txid = Sha256dHash::from(read_bytes!(32)); let outputs_count = byte_utils::slice_to_be64(read_bytes!(8)); - if outputs_count > data.len() as u64 * 32 { return None; } + if outputs_count > data.len() as u64 / 32 { return None; } let mut outputs = Vec::with_capacity(outputs_count as usize); for _ in 0..outputs_count { outputs.push(read_htlc_in_commitment!());