Skip to content

Commit 7446b08

Browse files
authored
disable compiler to prevent get_current_target() crash (#4251)
1 parent 3cce6fd commit 7446b08

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ if(NOT WAMR_BUILD_INTERP)
77
endif()
88

99
set(WAMR_BUILD_WAMR_COMPILER 1)
10-
set(WAMR_BUILD_AOT 1)
10+
set(WAMR_BUILD_AOT 0)
1111
set(WAMR_BUILD_INTERP 1)
1212
set(WAMR_BUILD_JIT 0)
1313

@@ -69,7 +69,7 @@ target_link_libraries(aotclib PUBLIC ${REQUIRED_LLVM_LIBS})
6969

7070
if(NOT IN_OSS_FUZZ)
7171
message(STATUS "Enable ASan and UBSan in non-oss-fuzz environment")
72-
target_compile_options(aotclib PUBLIC
72+
target_compile_options(aotclib PUBLIC
7373
-fprofile-instr-generate -fcoverage-mapping
7474
-fno-sanitize-recover=all
7575
-fsanitize=address,undefined

tests/fuzz/wasm-mutator-fuzz/aot-compiler/aot_compiler_fuzz.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
3535
/* libfuzzer don't allow to modify the given Data, so make a copy here */
3636
std::vector<uint8_t> myData(Data, Data + Size);
3737

38+
if (Size >= 4
39+
&& get_package_type(myData.data(), Size) != Wasm_Module_Bytecode) {
40+
printf("Invalid wasm file: magic header not detected\n");
41+
return 0;
42+
}
43+
3844
wasm_runtime_init();
3945

4046
module = wasm_runtime_load((uint8_t *)myData.data(), Size, error_buf, 120);

0 commit comments

Comments
 (0)