fix(interface-types) Cast index to usize to compare index to length.

The index is bound to `u32::max_value()`. The invocation inputs'
length is bound to `usize::max_value()`, which can be
`u64::max_value`. Consequently, casting the invocation inputs' length
to `u32` can lead to an integer overflow. It is better to cast `index`
to `usize` when comparing with the invocation inputs' length.
This commit is contained in:
Ivan Enderlin 2020-03-26 07:46:59 +01:00
parent 63f824a240
commit b63ce1be6c

View File

@ -8,7 +8,7 @@ executable_instruction!(
move |runtime| -> _ {
let invocation_inputs = runtime.invocation_inputs;
if index >= (invocation_inputs.len() as u32) {
if (index as usize) >= invocation_inputs.len() {
return Err(InstructionError::new(
instruction,
InstructionErrorKind::InvocationInputIsMissing { index },