Fix two issues to make fuzzing test quit earlier (#3471)

- Add a marco to limit the maxi allocable memory size of fuzz test to
  2GB to avoid libFuzzer out-of-memory
- Check global type in load_global_import and load_global_section
This commit is contained in:
liang.he
2024-05-30 14:55:21 +08:00
committed by GitHub
parent a2a8b32456
commit d29802c451
4 changed files with 27 additions and 3 deletions

View File

@ -663,4 +663,17 @@
#define WASM_MEM_ALLOC_WITH_USAGE 0
#endif
#ifndef WASM_ENABLE_FUZZ_TEST
#define WASM_ENABLE_FUZZ_TEST 0
#endif
#ifndef WASM_MEM_ALLOC_MAX_SIZE
#if WASM_ENABLE_FUZZ_TEST != 0
/* In oss-fuzz, the maximum RAM is ~2.5G */
#define WASM_MEM_ALLOC_MAX_SIZE (2U * 1024 * 1024 * 1024)
#else
#define WASM_MEM_ALLOC_MAX_SIZE UINT32_MAX
#endif
#endif
#endif /* end of _CONFIG_H_ */