From: Matt Corallo <649246+TheBlueMatt@users.noreply.github.com> Date: Sun, 26 Aug 2018 19:36:58 +0000 (-0400) Subject: Merge pull request #130 from TheBlueMatt/2018-08-fuzz-fixes-6 X-Git-Tag: v0.0.12~339 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=a33b3a269517f9721db2225a29d27eb03bb16431;hp=a66e597e958584b7fbfff8f5891d656010cd58fa;p=rust-lightning Merge pull request #130 from TheBlueMatt/2018-08-fuzz-fixes-6 Fix crash introduced in #124 --- diff --git a/src/ln/channel.rs b/src/ln/channel.rs index 47c05de2..d6e23a28 100644 --- a/src/ln/channel.rs +++ b/src/ln/channel.rs @@ -1018,10 +1018,13 @@ impl Channel { for (idx, htlc) in self.pending_htlcs.iter().enumerate() { if !htlc.outbound && htlc.payment_hash == payment_hash_calc && htlc.state != HTLCState::LocalRemoved && htlc.state != HTLCState::LocalRemovedAwaitingCommitment { - if pending_idx != std::usize::MAX { - panic!("Duplicate HTLC payment_hash, ChannelManager should have prevented this!"); + if let Some(PendingHTLCStatus::Fail(_)) = htlc.pending_forward_state { + } else { + if pending_idx != std::usize::MAX { + panic!("Duplicate HTLC payment_hash, ChannelManager should have prevented this!"); + } + pending_idx = idx; } - pending_idx = idx; } } if pending_idx == std::usize::MAX { diff --git a/src/ln/channelmanager.rs b/src/ln/channelmanager.rs index 20e6f373..a360c376 100644 --- a/src/ln/channelmanager.rs +++ b/src/ln/channelmanager.rs @@ -2256,7 +2256,6 @@ mod tests { chain_monitor: Arc, tx_broadcaster: Arc, chan_monitor: Arc, - node_id: SecretKey, node: Arc, router: Router, } @@ -2803,7 +2802,7 @@ mod tests { }; let node = ChannelManager::new(node_id.clone(), 0, true, Network::Testnet, feeest.clone(), chan_monitor.clone(), chain_monitor.clone(), tx_broadcaster.clone(), Arc::clone(&logger)).unwrap(); let router = Router::new(PublicKey::from_secret_key(&secp_ctx, &node_id), Arc::clone(&logger)); - nodes.push(Node { feeest, chain_monitor, tx_broadcaster, chan_monitor, node_id, node, router }); + nodes.push(Node { feeest, chain_monitor, tx_broadcaster, chan_monitor, node, router }); } nodes