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
let check_sorted = |list: &Vec<u64>| {
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)?;