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

@ -3511,6 +3511,8 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
uint32 opcode1;
read_leb_uint32(frame_ip, frame_ip_end, opcode1);
/* opcode1 was checked in loader and is no larger than
UINT8_MAX */
opcode = (uint8)opcode1;
switch (opcode) {
@ -3843,8 +3845,12 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
HANDLE_OP(WASM_OP_ATOMIC_PREFIX)
{
uint32 offset = 0, align, addr;
uint32 opcode1;
opcode = *frame_ip++;
read_leb_uint32(frame_ip, frame_ip_end, opcode1);
/* opcode1 was checked in loader and is no larger than
UINT8_MAX */
opcode = (uint8)opcode1;
if (opcode != WASM_OP_ATOMIC_FENCE) {
read_leb_uint32(frame_ip, frame_ip_end, align);