Repository navigation
Make after_export parser callback pass a WasmExport* instead of just int - #1
Merged
Merged
Conversation
This allows getting the export name without having to get the module and peek at the back of the export vector.
Member
|
lgtm |
binji
added a commit
that referenced
this pull request
Sep 14, 2015
Make after_export parser callback pass a WasmExport* instead of just int
sumayyanc
pushed a commit
to pose-dev/wabt
that referenced
this pull request
Aug 2, 2019
Install for libtester
dimitry-
pushed a commit
to dimitry-/wabt
that referenced
this pull request
Nov 8, 2022
Write imported functions in no-sandbox mode
Closed
sbc100
pushed a commit
that referenced
this pull request
Jun 13, 2026
UBSan, decompiling a module that addresses memory as (base + (index <<
n)):
src/decompiler.cc:325:21: runtime error: shift exponent 64 is too large
for 64-bit type 'unsigned long long'
#0 wabt::Decompiler::LoadStore(...) decompiler.cc:325
#1 wabt::Decompiler::DecompileExpr(...) decompiler.cc:489
The load/store printer recognises that address shape and tries to
rewrite it to base[index], testing 1ULL << n against the access
alignment. n is the i32.const operand of the i32.shl, read straight from
the module. i32.shl masks its shift amount at runtime, so n is otherwise
unconstrained; n >= 64 pushes the exponent past the width of the type
and the shift is undefined.
Bounding n < 64 before the shift loses no real match, since the
alignment it is compared against is always a small power of two. The
unmatched shape then prints verbatim, the same as a mismatched shift
already does.
Repro is a load of (local 0 + (local 1 << 64)): UBSan aborts at
decompiler.cc:325 before, decompiles to (a + (b << 64))[0]:int after.
Covered by the loadstore decompile test.
sbc100
pushed a commit
that referenced
this pull request
Jun 24, 2026
UBSan, `wasm-objdump -x` on a crafted module:
binary-reader-objdump.cc:69:12: runtime error: index
18446744073709551615 out of bounds for type 'const Offset[14]'
#0 BinaryReaderObjdumpBase::GetSectionStart binary-reader-objdump.cc:69
#1 BinaryReaderObjdump::OnReloc binary-reader-objdump.cc:2176
The input is a `reloc.*` custom section whose section index points past
the last section. The base `OnRelocCount` spots that, sets
`reloc_section_` to `BinarySection::Invalid` (`~0`) and returns `Error`
to abort the section. The details-mode override dropped that result and
returned `Ok`, so `ReadRelocSection` carried on into `OnReloc`, where
`GetSectionStart(reloc_section_)` reads `section_starts_[(size_t)-1]`.
`Result` is not `[[nodiscard]]`, so the dropped error built clean.
Propagating it with `CHECK_RESULT` rejects the bad index the same way
the other reader modes already do.
`bad-relocs.txt` used a zero relocation count, so it never reached
`OnReloc`; gave it one entry so it covers the read.
sbc100
pushed a commit
that referenced
this pull request
Jul 13, 2026
ASan, release build, `wasm2wat` on a crafted module:
==…==ERROR: AddressSanitizer: heap-buffer-overflow
#0 wabt::MakeTypeBindingReverseMapping(...) ir.cc
#1 wabt::ApplyNames(wabt::Module*)
#2 ProgramMain
... located 1535 bytes after 24-byte region
Found while going over the name-section handlers. The local subsection
stores a (local index, name) pair per entry. `OnLocalNameLocalCount`
checks the entry count against the function's param+local count, but the
per-entry local index in `OnLocalName` is never range-checked before it
becomes a `Binding`. `MakeTypeBindingReverseMapping` sizes the reverse
map to that local count and writes each name at `binding.index`, guarded
only by an `assert`. A name whose index sits past the function's locals
writes off the end of the vector: a debug build trips the assert, a
release build corrupts the heap. Reached from an untrusted `.wasm`
through `wasm2wat` and `wasm2c` (both call `ApplyNames` and read debug
names by default), on an otherwise valid module.
Skip entries that land outside the mapping. Valid modules only name real
locals, so their output does not change. The added test names local
index 5 of a one-param function; before the fix `wasm2wat` aborts, after
it prints the module with the stray name dropped.
sbc100
pushed a commit
that referenced
this pull request
Jul 29, 2026
ASan, `spectest-interp --trace` on a module that imports a global and
also defines one:
==73766==ERROR: AddressSanitizer: heap-buffer-overflow on address
0x60e0000002a4
READ of size 8 at 0x60e0000002a4 thread T0
#1 Thread::TraceSource::GetGlobalType(unsigned int) interp.cc:3022
#2 Thread::TraceSource::Pick(unsigned int, Instr) interp.cc:2954
#3 Istream::Trace(...) istream.cc:887
0x60e0000002a4 is located 12 bytes after 152-byte region
[0x60e000000200,0x60e000000298)
Noticed it while reading the trace helpers. `ModuleDesc::globals` and
`ModuleDesc::tables` hold only the defined entries, imports live in
`ModuleDesc::imports`. But the `global.set`/`table.*` immediate is the
module-level index, which counts imports first. One imported global plus
one defined global is already enough to run off the end.
`GetTableElementType` has the same shape at interp.cc:3026, reached from
`table.grow` and `table.fill`.
The garbage `ValueType` that comes back then decides how the operand
`Value` is read, so a debug build aborts on the `CheckType` assert in
interp.h and a release build prints an arbitrary reference index.
Both immediates now resolve against the instance, which is what the
`GlobalSet`, `DoTableGrow` and `DoTableFill` handlers already do.
Regression test added under test/interp.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This allows getting the export name without having to get the module and
peek at the back of the export vector.