]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Fix an incorrect assertion in tlv stream encoding
authorOmer Yacine <mariocynicys@gmail.com>
Wed, 2 Nov 2022 15:32:47 +0000 (17:32 +0200)
committerOmer Yacine <mariocynicys@gmail.com>
Mon, 9 Jan 2023 19:20:23 +0000 (21:20 +0200)
Types must be unique and monotonically increasing (using < instead of <=)

lightning/src/util/ser_macros.rs

index 2ed3683f43fe6938d2fec9118d5f2c2bcb45bda7..d137b0f677bcda557276701d8f7380eab9eb17cb 100644 (file)
@@ -55,7 +55,8 @@ macro_rules! _check_encoded_tlv_order {
        ($last_type: expr, $type: expr, (static_value, $value: expr)) => { };
        ($last_type: expr, $type: expr, $fieldty: tt) => {
                if let Some(t) = $last_type {
-                       debug_assert!(t <= $type);
+                       #[allow(unused_comparisons)] // Note that $type may be 0 making the following comparison always false
+                       (debug_assert!(t < $type))
                }
                $last_type = Some($type);
        };