WebAssembly / spec

WebAssembly specification, reference interpreter, and test suite.
https://webassembly.github.io/spec/
Other
3.09k stars 438 forks source link

test(binary.wast): adjust br_table length test to work with streaming validation #1715

Closed rvagg closed 6 months ago

rvagg commented 6 months ago

Current implementation fails on streaming validation due to interpreting 0x020x0b as block with type 11 which doesn't exist; so add enough types such that 0x0b resolves to a valid one, thereby passing validation and erroring at the expected state.

This was previously reported in https://github.com/WebAssembly/spec/issues/1355 but never fixed, and I've just discovered it for myself.

Suggestions for making this more realistic or safe welcome! I'm a bit concerned about adding so many duplicate types in here but I don't believe that's illegal according to spec. My first pass at this changed the first 0x0b to an 0x00 but that breaks the realism a bit too much since you need the 3 breaks and the wild 0x00 makes no sense. The test is trying to get at the br_table having a missing byte.