From ab22bed7edfdf14e234fd333267b700ba59b093a Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Mon, 23 Jul 2018 14:53:34 -0400 Subject: [PATCH] Fix OOM crash in ChannelMonitor::deserialize found by AFL --- src/ln/channelmonitor.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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!()); -- 2.39.5