Skip to content

Commit

Permalink
fast-interp: Fix frame_offset overflow issue (bytecodealliance#3149)
Browse files Browse the repository at this point in the history
The issue was found in bytecodealliance#3137.
  • Loading branch information
xujuntwt95329 authored Feb 8, 2024
1 parent 48ea84e commit 9163bf0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
11 changes: 9 additions & 2 deletions core/iwasm/interpreter/wasm_loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -10796,8 +10796,15 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func,
* Since the stack is already in polymorphic state,
* the opcode will not be executed, so the dummy
* offset won't cause any error */
*loader_ctx->frame_offset++ = 0;
if (cell_num > 1) {
uint32 n;

for (n = 0; n < cell_num; n++) {
if (loader_ctx->p_code_compiled == NULL) {
if (!check_offset_push(loader_ctx,
error_buf,
error_buf_size))
goto fail;
}
*loader_ctx->frame_offset++ = 0;
}
}
Expand Down
11 changes: 9 additions & 2 deletions core/iwasm/interpreter/wasm_mini_loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -5931,8 +5931,15 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func,
* Since the stack is already in polymorphic state,
* the opcode will not be executed, so the dummy
* offset won't cause any error */
*loader_ctx->frame_offset++ = 0;
if (cell_num > 1) {
uint32 n;

for (n = 0; n < cell_num; n++) {
if (loader_ctx->p_code_compiled == NULL) {
if (!check_offset_push(loader_ctx,
error_buf,
error_buf_size))
goto fail;
}
*loader_ctx->frame_offset++ = 0;
}
}
Expand Down

0 comments on commit 9163bf0

Please sign in to comment.