Skip to content

Commit 311aaec

Browse files
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.
1 parent 5d74cae commit 311aaec

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

lightning/src/ln/msgs.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ pub enum DecodeError {
6363
/// Error from std::io
6464
Io(/// (C-not exported) as ErrorKind doesn't have a reasonable mapping
6565
::std::io::ErrorKind),
66+
/// The message included zlib-compressed values, which we don't support.
67+
ZlibCompressedUnsupported,
6668
}
6769

6870
/// An init message to be sent or received from a peer
@@ -953,6 +955,7 @@ impl fmt::Display for DecodeError {
953955
DecodeError::ShortRead => f.write_str("Packet extended beyond the provided bytes"),
954956
DecodeError::BadLengthDescriptor => f.write_str("A length descriptor in the packet didn't describe the later data correctly"),
955957
DecodeError::Io(ref e) => e.fmt(f),
958+
DecodeError::ZlibCompressedUnsupported => f.write_str("We don't support receiving messages with zlib-compressed fields"),
956959
}
957960
}
958961
}

lightning/src/ln/peer_handler.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,10 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, L: Deref> PeerManager<D
783783
}
784784
msgs::DecodeError::BadLengthDescriptor => return Err(PeerHandleError { no_connection_possible: false }),
785785
msgs::DecodeError::Io(_) => return Err(PeerHandleError { no_connection_possible: false }),
786+
msgs::DecodeError::ZlibCompressedUnsupported => {
787+
log_debug!(self.logger, "We don't support zlib-compressed message fields, ignoring message");
788+
continue;
789+
}
786790
}
787791
}
788792
};

0 commit comments

Comments
 (0)