From 59552e30a5dd13875f56446315396746c3756596 Mon Sep 17 00:00:00 2001 From: Zk-nd3r Date: Wed, 29 Jul 2026 11:44:57 -0700 Subject: [PATCH] fix reversed empty range in FatPointerToBftBlock::try_from_bytes bytes[76 - 32..2] is bytes[44..2], a reversed range that panics on the first decode. The length guard above admits any input of 46 bytes or more, and the 2-byte signature-count field that follows the 44-byte vote header lives at bytes[44..46]. Fix the range and drop the clippy::reversed_empty_ranges allow that was hiding it. --- librustzcash/zcash_primitives/src/bft.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/librustzcash/zcash_primitives/src/bft.rs b/librustzcash/zcash_primitives/src/bft.rs index 76d24069..0925f70c 100644 --- a/librustzcash/zcash_primitives/src/bft.rs +++ b/librustzcash/zcash_primitives/src/bft.rs @@ -685,13 +685,12 @@ impl FatPointerToBftBlock { buf } - #[allow(clippy::reversed_empty_ranges)] pub fn try_from_bytes(bytes: &[u8]) -> Option { if bytes.len() < 76 - 32 + 2 { return None; } let vote_for_block_without_finalizer_public_key = bytes[0..76 - 32].try_into().unwrap(); - let len = u16::from_le_bytes(bytes[76 - 32..2].try_into().unwrap()) as usize; + let len = u16::from_le_bytes(bytes[76 - 32..76 - 32 + 2].try_into().unwrap()) as usize; if 76 - 32 + 2 + len * (32 + 64) > bytes.len() { return None;