Fix read and validation of misc/simd/atomic sub opcodes (#3115)

The format of sub opcodes after misc, simd and atomic prefix is leb u32.

The issue was found in #2921.
This commit is contained in:
Wenyong Huang
2024-02-02 12:03:58 +08:00
committed by GitHub
parent b3f728ceb3
commit 2eb60060d8
7 changed files with 75 additions and 28 deletions

View File

@ -627,8 +627,10 @@ main(int argc, char *argv[])
goto fail1;
}
if (get_package_type(wasm_file, wasm_file_size) != Wasm_Module_Bytecode) {
printf("Invalid file type: expected wasm file but got other\n");
if (wasm_file_size >= 4 /* length of MAGIC NUMBER */
&& get_package_type(wasm_file, wasm_file_size)
!= Wasm_Module_Bytecode) {
printf("Invalid wasm file: magic header not detected\n");
goto fail2;
}