Skip to content

Commit

Permalink
Allow all LEB128 encodings of zero for table index
Browse files Browse the repository at this point in the history
Even without reference types, the table index can be encoded in multiple
ways (e.g. `0x80 0x00`). This fixes the handling of these (valid) files
by always reading the table index as a LEB128.
  • Loading branch information
jkrems committed Aug 7, 2024
1 parent 1362a30 commit 29811a1
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 10 deletions.
5 changes: 0 additions & 5 deletions core/iwasm/interpreter/wasm_loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -12082,12 +12082,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func,
WASMFuncType *func_type;

read_leb_uint32(p, p_end, type_idx);
#if WASM_ENABLE_REF_TYPES != 0 || WASM_ENABLE_GC != 0
read_leb_uint32(p, p_end, table_idx);
#else
CHECK_BUF(p, p_end, 1);
table_idx = read_uint8(p);
#endif
if (!check_table_index(module, table_idx, error_buf,
error_buf_size)) {
goto fail;
Expand Down
5 changes: 0 additions & 5 deletions core/iwasm/interpreter/wasm_mini_loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -6592,12 +6592,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func,

read_leb_uint32(p, p_end, type_idx);

#if WASM_ENABLE_REF_TYPES != 0
read_leb_uint32(p, p_end, table_idx);
#else
CHECK_BUF(p, p_end, 1);
table_idx = read_uint8(p);
#endif
if (!check_table_index(module, table_idx, error_buf,
error_buf_size)) {
goto fail;
Expand Down

0 comments on commit 29811a1

Please sign in to comment.