Skip to content

Commit 0c10c84

Browse files
committed
Fix off-by-one in aot_alloc_tiny_frame overflow check
The boundary check in aot_alloc_tiny_frame only verifies that new_frame itself doesn't exceed top_boundary, but doesn't account for the sizeof(AOTTinyFrame) bytes that are about to be written. When new_frame equals top_boundary exactly, the check passes but the subsequent write to new_frame->func_index goes past the boundary. This matches the correct pattern used in aot_alloc_frame (line 4086) which includes the frame size.
1 parent c46b10d commit 0c10c84

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

core/iwasm/aot/aot_runtime.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4176,7 +4176,7 @@ aot_alloc_tiny_frame(WASMExecEnv *exec_env, uint32 func_index)
41764176
{
41774177
AOTTinyFrame *new_frame = (AOTTinyFrame *)exec_env->wasm_stack.top;
41784178

4179-
if ((uint8 *)new_frame > exec_env->wasm_stack.top_boundary) {
4179+
if ((uint8 *)new_frame + sizeof(AOTTinyFrame) > exec_env->wasm_stack.top_boundary) {
41804180
aot_set_exception((WASMModuleInstance *)exec_env->module_inst,
41814181
"wasm operand stack overflow");
41824182
return false;

0 commit comments

Comments
 (0)