Skip to content

Commit 51905a5

Browse files
committed
Fix off-by-one error in result offset calculation for function calls
1 parent 2538eae commit 51905a5

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

core/iwasm/interpreter/wasm_interp_fast.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ typedef float64 CellType_F64;
4343
&& (app_addr) <= shared_heap_end_off - bytes + 1)
4444

4545
#define shared_heap_addr_app_to_native(app_addr, native_addr) \
46-
native_addr = shared_heap_base_addr + ((app_addr)-shared_heap_start_off)
46+
native_addr = shared_heap_base_addr + ((app_addr) - shared_heap_start_off)
4747

4848
#define CHECK_SHARED_HEAP_OVERFLOW(app_addr, bytes, native_addr) \
4949
if (app_addr_in_shared_heap(app_addr, bytes)) \
@@ -1670,7 +1670,8 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
16701670
{
16711671
uint32 ret_idx;
16721672
WASMFuncType *func_type;
1673-
uint32 off, ret_offset;
1673+
int32 off;
1674+
uint32 ret_offset;
16741675
uint8 *ret_types;
16751676
if (cur_func->is_import_func)
16761677
func_type = cur_func->u.func_import->func_type;
@@ -1682,9 +1683,9 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
16821683
ret_offset = prev_frame->ret_offset;
16831684

16841685
for (ret_idx = 0,
1685-
off = sizeof(int16) * (func_type->result_count - 1);
1686+
off = (int32)sizeof(int16) * (func_type->result_count - 1);
16861687
ret_idx < func_type->result_count;
1687-
ret_idx++, off -= sizeof(int16)) {
1688+
ret_idx++, off -= (int32)sizeof(int16)) {
16881689
if (ret_types[ret_idx] == VALUE_TYPE_I64
16891690
|| ret_types[ret_idx] == VALUE_TYPE_F64) {
16901691
PUT_I64_TO_ADDR(prev_frame->lp + ret_offset,

tests/fuzz/wasm-mutator-fuzz/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ endif ()
7272

7373
if (NOT DEFINED WAMR_BUILD_LIBC_WASI)
7474
# Enable libc wasi support by default
75-
set (WAMR_BUILD_LIBC_WASI 1)
75+
set (WAMR_BUILD_LIBC_WASI 0)
7676
endif ()
7777

7878
if (NOT DEFINED WAMR_BUILD_FAST_INTERP)

0 commit comments

Comments
 (0)