@@ -63,6 +63,8 @@ pub enum DecodeError {
63
63
/// Error from std::io
64
64
Io ( /// (C-not exported) as ErrorKind doesn't have a reasonable mapping
65
65
:: std:: io:: ErrorKind ) ,
66
+ /// The message included zlib-compressed values, which we don't support.
67
+ UnsupportedCompression ,
66
68
}
67
69
68
70
/// An init message to be sent or received from a peer
@@ -953,6 +955,7 @@ impl fmt::Display for DecodeError {
953
955
DecodeError :: ShortRead => f. write_str ( "Packet extended beyond the provided bytes" ) ,
954
956
DecodeError :: BadLengthDescriptor => f. write_str ( "A length descriptor in the packet didn't describe the later data correctly" ) ,
955
957
DecodeError :: Io ( ref e) => e. fmt ( f) ,
958
+ DecodeError :: UnsupportedCompression => f. write_str ( "We don't support receiving messages with zlib-compressed fields" ) ,
956
959
}
957
960
}
958
961
}
@@ -1634,17 +1637,18 @@ impl Readable for QueryShortChannelIds {
1634
1637
fn read < R : Read > ( r : & mut R ) -> Result < Self , DecodeError > {
1635
1638
let chain_hash: BlockHash = Readable :: read ( r) ?;
1636
1639
1637
- // We expect the encoding_len to always includes the 1-byte
1638
- // encoding_type and that short_channel_ids are 8-bytes each
1639
1640
let encoding_len: u16 = Readable :: read ( r) ?;
1640
- if encoding_len == 0 || ( encoding_len - 1 ) % 8 != 0 {
1641
- return Err ( DecodeError :: InvalidValue ) ;
1642
- }
1641
+ let encoding_type: u8 = Readable :: read ( r) ?;
1643
1642
1644
1643
// Must be encoding_type=0 uncompressed serialization. We do not
1645
1644
// support encoding_type=1 zlib serialization.
1646
- let encoding_type: u8 = Readable :: read ( r) ?;
1647
1645
if encoding_type != EncodingType :: Uncompressed as u8 {
1646
+ return Err ( DecodeError :: UnsupportedCompression ) ;
1647
+ }
1648
+
1649
+ // We expect the encoding_len to always includes the 1-byte
1650
+ // encoding_type and that short_channel_ids are 8-bytes each
1651
+ if encoding_len == 0 || ( encoding_len - 1 ) % 8 != 0 {
1648
1652
return Err ( DecodeError :: InvalidValue ) ;
1649
1653
}
1650
1654
@@ -1746,17 +1750,18 @@ impl Readable for ReplyChannelRange {
1746
1750
let number_of_blocks: u32 = Readable :: read ( r) ?;
1747
1751
let sync_complete: bool = Readable :: read ( r) ?;
1748
1752
1749
- // We expect the encoding_len to always includes the 1-byte
1750
- // encoding_type and that short_channel_ids are 8-bytes each
1751
1753
let encoding_len: u16 = Readable :: read ( r) ?;
1752
- if encoding_len == 0 || ( encoding_len - 1 ) % 8 != 0 {
1753
- return Err ( DecodeError :: InvalidValue ) ;
1754
- }
1754
+ let encoding_type: u8 = Readable :: read ( r) ?;
1755
1755
1756
1756
// Must be encoding_type=0 uncompressed serialization. We do not
1757
1757
// support encoding_type=1 zlib serialization.
1758
- let encoding_type: u8 = Readable :: read ( r) ?;
1759
1758
if encoding_type != EncodingType :: Uncompressed as u8 {
1759
+ return Err ( DecodeError :: UnsupportedCompression ) ;
1760
+ }
1761
+
1762
+ // We expect the encoding_len to always includes the 1-byte
1763
+ // encoding_type and that short_channel_ids are 8-bytes each
1764
+ if encoding_len == 0 || ( encoding_len - 1 ) % 8 != 0 {
1760
1765
return Err ( DecodeError :: InvalidValue ) ;
1761
1766
}
1762
1767
0 commit comments