Fix underflow in verify_indexed_attestation

This commit is contained in:
Paul Hauner 2019-05-24 01:03:49 +10:00
parent 67f890ae48
commit 55ef75a44e
No known key found for this signature in database
GPG Key ID: 5E2CFF9B75FA63DF

View File

@ -62,11 +62,13 @@ fn verify_indexed_attestation_parametric<T: EthSpec>(
// Check that both vectors of indices are sorted // Check that both vectors of indices are sorted
let check_sorted = |list: &Vec<u64>| { let check_sorted = |list: &Vec<u64>| {
for i in 0..list.len() - 1 { list.windows(2).enumerate().try_for_each(|(i, pair)| {
if list[i] >= list[i + 1] { if pair[0] >= pair[1] {
invalid!(Invalid::BadValidatorIndicesOrdering(i)); invalid!(Invalid::BadValidatorIndicesOrdering(i));
} else {
Ok(())
} }
} })?;
Ok(()) Ok(())
}; };
check_sorted(custody_bit_0_indices)?; check_sorted(custody_bit_0_indices)?;