Refine aot stack overflow check and enhance wasm loader malformed checks (#248)
And separate global data from wasm memory instance
This commit is contained in:
@ -1959,12 +1959,14 @@ aot_load_from_comp_data(AOTCompData *comp_data, AOTCompContext *comp_ctx,
|
||||
|
||||
module->start_func_index = comp_data->start_func_index;
|
||||
if (comp_data->start_func_index != (uint32)-1) {
|
||||
bh_assert(comp_data->start_func_index >= module->import_func_count
|
||||
&& comp_data->start_func_index < module->import_func_count
|
||||
+ module->func_count);
|
||||
module->start_function =
|
||||
module->func_ptrs[comp_data->start_func_index
|
||||
- module->import_func_count];
|
||||
bh_assert(comp_data->start_func_index < module->import_func_count
|
||||
+ module->func_count);
|
||||
/* TODO: fix issue that start func cannot be import func */
|
||||
if (comp_data->start_func_index >= module->import_func_count) {
|
||||
module->start_function =
|
||||
module->func_ptrs[comp_data->start_func_index
|
||||
- module->import_func_count];
|
||||
}
|
||||
}
|
||||
else {
|
||||
module->start_function = NULL;
|
||||
|
||||
@ -897,6 +897,15 @@ aot_call_indirect(WASMExecEnv *exec_env,
|
||||
void *attachment = NULL;
|
||||
char buf[128];
|
||||
|
||||
/* this function is called from native code, so exec_env->handle and
|
||||
exec_env->native_stack_boundary must have been set, we don't set
|
||||
it again */
|
||||
|
||||
if ((uint8*)&module_inst < exec_env->native_stack_boundary) {
|
||||
aot_set_exception_with_id(module_inst, EXCE_NATIVE_STACK_OVERFLOW);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (table_elem_idx >= table_size) {
|
||||
aot_set_exception_with_id(module_inst, EXCE_UNDEFINED_ELEMENT);
|
||||
return false;
|
||||
@ -941,15 +950,6 @@ aot_call_indirect(WASMExecEnv *exec_env,
|
||||
}
|
||||
}
|
||||
|
||||
/* this function is called from native code, so exec_env->handle and
|
||||
exec_env->native_stack_boundary must have been set, we don't set
|
||||
it again */
|
||||
|
||||
if ((uint8*)&module_inst < exec_env->native_stack_boundary) {
|
||||
aot_set_exception_with_id(module_inst, EXCE_NATIVE_STACK_OVERFLOW);
|
||||
return false;
|
||||
}
|
||||
|
||||
return wasm_runtime_invoke_native(exec_env, func_ptr,
|
||||
func_type, signature, attachment,
|
||||
argv, argc, argv);
|
||||
|
||||
Reference in New Issue
Block a user