From 55ef75a44eb17bf5ecf6737ccf8f6e5987598993 Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Fri, 24 May 2019 01:03:49 +1000 Subject: [PATCH] Fix underflow in verify_indexed_attestation --- .../per_block_processing/verify_indexed_attestation.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/eth2/state_processing/src/per_block_processing/verify_indexed_attestation.rs b/eth2/state_processing/src/per_block_processing/verify_indexed_attestation.rs index adaf336ccf..6581e516de 100644 --- a/eth2/state_processing/src/per_block_processing/verify_indexed_attestation.rs +++ b/eth2/state_processing/src/per_block_processing/verify_indexed_attestation.rs @@ -62,11 +62,13 @@ fn verify_indexed_attestation_parametric( // Check that both vectors of indices are sorted let check_sorted = |list: &Vec| { - for i in 0..list.len() - 1 { - if list[i] >= list[i + 1] { + list.windows(2).enumerate().try_for_each(|(i, pair)| { + if pair[0] >= pair[1] { invalid!(Invalid::BadValidatorIndicesOrdering(i)); + } else { + Ok(()) } - } + })?; Ok(()) }; check_sorted(custody_bit_0_indices)?;