From: Valentine Wallace Date: Wed, 19 May 2021 18:05:03 +0000 (-0400) Subject: Add new DecodeError for messages that include zlib-compressed values X-Git-Tag: v0.0.98~23^2~1 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=438e70e083fbe52338be5de3ce95b0f1dabb6267;p=rust-lightning Add new DecodeError for messages that include zlib-compressed values No need to disconnect peers if this error is encountered. It just means we can't use some of their gossip messages. --- diff --git a/fuzz/src/router.rs b/fuzz/src/router.rs index f9a263cc3..d0f7b1321 100644 --- a/fuzz/src/router.rs +++ b/fuzz/src/router.rs @@ -133,6 +133,7 @@ pub fn do_test(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, } } }} diff --git a/lightning/src/ln/msgs.rs b/lightning/src/ln/msgs.rs index be99596be..d5ad0205c 100644 --- a/lightning/src/ln/msgs.rs +++ b/lightning/src/ln/msgs.rs @@ -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"), } } } diff --git a/lightning/src/ln/peer_handler.rs b/lightning/src/ln/peer_handler.rs index 2559acfc2..f9e794299 100644 --- a/lightning/src/ln/peer_handler.rs +++ b/lightning/src/ln/peer_handler.rs @@ -783,6 +783,10 @@ impl PeerManager 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; + } } } };