Add new DecodeError for messages that include zlib-compressed values
authorValentine Wallace <vwallace@protonmail.com>
Wed, 19 May 2021 18:05:03 +0000 (14:05 -0400)
committerValentine Wallace <vwallace@protonmail.com>
Thu, 20 May 2021 15:25:39 +0000 (11:25 -0400)
No need to disconnect peers if this error is encountered. It just means
we can't use some of their gossip messages.

fuzz/src/router.rs
lightning/src/ln/msgs.rs
lightning/src/ln/peer_handler.rs

index f9a263cc3254556036bc4640d07f40a9df6179d4..d0f7b13219fb3adb29b22715dee471cfc8b85332 100644 (file)
@@ -133,6 +133,7 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
                                        msgs::DecodeError::BadLengthDescriptor => return,
                                        msgs::DecodeError::ShortRead => panic!("We picked the length..."),
                                        msgs::DecodeError::Io(e) => panic!("{:?}", e),
+                                       msgs::DecodeError::UnsupportedCompression => return,
                                }
                        }
                }}
index be99596becd82d4627c21c229d9b6172ac385615..d5ad0205c9d0fda8630034bf68913f6111a20b61 100644 (file)
@@ -63,6 +63,8 @@ pub enum DecodeError {
        /// Error from std::io
        Io(/// (C-not exported) as ErrorKind doesn't have a reasonable mapping
         ::std::io::ErrorKind),
+       /// The message included zlib-compressed values, which we don't support.
+       UnsupportedCompression,
 }
 
 /// An init message to be sent or received from a peer
@@ -953,6 +955,7 @@ impl fmt::Display for DecodeError {
                        DecodeError::ShortRead => f.write_str("Packet extended beyond the provided bytes"),
                        DecodeError::BadLengthDescriptor => f.write_str("A length descriptor in the packet didn't describe the later data correctly"),
                        DecodeError::Io(ref e) => e.fmt(f),
+                       DecodeError::UnsupportedCompression => f.write_str("We don't support receiving messages with zlib-compressed fields"),
                }
        }
 }
index 2559acfc2dd5370b93d59d1cdb47a591c80a1c56..f9e79429913dac7815ada3b90a6f7c58a7519bb5 100644 (file)
@@ -783,6 +783,10 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, L: Deref> PeerManager<D
                                                                                                        }
                                                                                                        msgs::DecodeError::BadLengthDescriptor => return Err(PeerHandleError { no_connection_possible: false }),
                                                                                                        msgs::DecodeError::Io(_) => return Err(PeerHandleError { no_connection_possible: false }),
+                                                                                                       msgs::DecodeError::UnsupportedCompression => {
+                                                                                                               log_debug!(self.logger, "We don't support zlib-compressed message fields, ignoring message");
+                                                                                                               continue;
+                                                                                                       }
                                                                                                }
                                                                                        }
                                                                                };