Skip to content

Commit 23df0d4

Browse files
authored
fix: correct boundary check in dynamic_offset check (#4788)
correct boundary check in check_dynamic_offset_pop when dynamic_offset is 0. When dynamic_offset = 0, check_dynamic_offset_pop will always return true, which may wrongly update dynamic_offset. also include a typo fix in SET_OPERAND_REF Signed-off-by: zhenweijin <zhenwei.jin@intel.com>
1 parent 29767f6 commit 23df0d4

File tree

3 files changed

+3
-5
lines changed

3 files changed

+3
-5
lines changed

core/iwasm/interpreter/wasm_interp_fast.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ wasm_interp_get_frame_ref(WASMInterpFrame *frame)
442442
opnd_off = *(int16 *)(frame_ip + off); \
443443
addr_tmp = frame_lp + opnd_off; \
444444
PUT_REF_TO_ADDR(addr_tmp, value); \
445-
SET_FRAME_REF(ond_off); \
445+
SET_FRAME_REF(opnd_off); \
446446
} while (0)
447447

448448
#define SET_OPERAND(op_type, off, value) SET_OPERAND_##op_type(off, value)

core/iwasm/interpreter/wasm_loader.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8545,8 +8545,7 @@ check_offset_pop(WASMLoaderContext *ctx, uint32 cells)
85458545
static bool
85468546
check_dynamic_offset_pop(WASMLoaderContext *ctx, uint32 cells)
85478547
{
8548-
if (ctx->dynamic_offset < 0
8549-
|| (ctx->dynamic_offset > 0 && (uint32)ctx->dynamic_offset < cells))
8548+
if (ctx->dynamic_offset < 0 || (uint32)ctx->dynamic_offset < cells)
85508549
return false;
85518550
return true;
85528551
}

core/iwasm/interpreter/wasm_mini_loader.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4345,8 +4345,7 @@ check_offset_pop(WASMLoaderContext *ctx, uint32 cells)
43454345
static bool
43464346
check_dynamic_offset_pop(WASMLoaderContext *ctx, uint32 cells)
43474347
{
4348-
if (ctx->dynamic_offset < 0
4349-
|| (ctx->dynamic_offset > 0 && (uint32)ctx->dynamic_offset < cells))
4348+
if (ctx->dynamic_offset < 0 || (uint32)ctx->dynamic_offset < cells)
43504349
return false;
43514350
return true;
43524351
}

0 commit comments

Comments
 (0)