]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Fix crash on no-witness tx in ChannelMonitor found by fuzzer
authorMatt Corallo <git@bluematt.me>
Sun, 2 Dec 2018 23:22:40 +0000 (18:22 -0500)
committerMatt Corallo <git@bluematt.me>
Mon, 3 Dec 2018 18:21:20 +0000 (13:21 -0500)
Tehnically we can't currently hit this, but a theoretical future
watchtower could, and full_stack_target crashes on it.

src/ln/channelmonitor.rs

index 6ce4b22d5a8c63109765be350c53883ad9d91855..cee406d000ef41f763d6853df4b70bce9396948c 100644 (file)
@@ -1386,7 +1386,7 @@ impl ChannelMonitor {
 
        /// Generate a spendable output event when closing_transaction get registered onchain.
        fn check_spend_closing_transaction(&self, tx: &Transaction) -> Option<SpendableOutputDescriptor> {
-               if tx.input[0].sequence == 0xFFFFFFFF && tx.input[0].witness.last().unwrap().len() == 71 {
+               if tx.input[0].sequence == 0xFFFFFFFF && !tx.input[0].witness.is_empty() && tx.input[0].witness.last().unwrap().len() == 71 {
                        match self.key_storage {
                                KeyStorage::PrivMode { ref shutdown_pubkey, .. } =>  {
                                        let our_channel_close_key_hash = Hash160::from_data(&shutdown_pubkey.serialize());