diff --git a/script/src/syscalls/exec.rs b/script/src/syscalls/exec.rs index a4758bdf3e..1e934fddf8 100644 --- a/script/src/syscalls/exec.rs +++ b/script/src/syscalls/exec.rs @@ -151,6 +151,7 @@ impl Syscalls for let data = if length == 0 { data.slice(offset..data_size) } else { + // Both offset and length are <= u32::MAX, so offset.checked_add(length) will be always a Some. let end = offset.checked_add(length).ok_or(VMError::MemOutOfBound)?; if end > data_size { machine.set_register(A0, Mac::REG::from_u8(SLICE_OUT_OF_BOUND)); diff --git a/script/src/syscalls/exec_v2.rs b/script/src/syscalls/exec_v2.rs index 6931f806f9..acac0079c5 100644 --- a/script/src/syscalls/exec_v2.rs +++ b/script/src/syscalls/exec_v2.rs @@ -94,6 +94,7 @@ where return Ok(true); } if length > 0 { + // Both offset and length are <= u32::MAX, so offset.checked_add(length) will be always a Some. let end = offset.checked_add(length).ok_or(VMError::MemOutOfBound)?; if end > full_length { machine.set_register(A0, Mac::REG::from_u8(SLICE_OUT_OF_BOUND)); @@ -101,8 +102,8 @@ where } } - let argc = machine.registers()[A4].clone(); - let argv = machine.registers()[A5].clone(); + let argc = machine.registers()[A4].to_u64(); + let argv = machine.registers()[A5].to_u64(); self.message_box .lock() .map_err(|e| VMError::Unexpected(e.to_string()))? @@ -112,8 +113,8 @@ where data_piece_id, offset, length, - argc: argc.to_u64(), - argv: argv.to_u64(), + argc: argc, + argv: argv, }, )); Err(VMError::Yield) diff --git a/script/src/verify.rs b/script/src/verify.rs index 3c16611c23..70eb0e7fea 100644 --- a/script/src/verify.rs +++ b/script/src/verify.rs @@ -182,6 +182,7 @@ where ) } + /// Build syscall: exec. When script version >= V2, this exec implementation is used. pub fn build_exec_v2( &self, snapshot2_context: Arc>>>,