wabt
wabt copied to clipboard
Incorrect functype decoding
The binary reader reads types (functype, but also structs and arrays) in type section using signed LEB128 encoding. The spec defines type as single byte. This causing problem because WABT accepts longer sequences of bytes as valid types while there are invalid in the spec.
I can change the Type::Enum
to be based on uint8_t
unless you think this will cause some problems with any extensions.
The related spectest from https://github.com/WebAssembly/spec/pull/1254.
;; Type section with signed LEB128 encoded type
(assert_malformed
(module binary
"\00asm" "\01\00\00\00"
"\01" ;; Type section id
"\05" ;; Type section length
"\01" ;; Types vector length
"\e0\7f" ;; Malformed functype, -0x20 in signed LEB128 encoding
"\00\00"
)
"integer representation too long"
)
It looks like restricting reading types to single byte breaks something related to relocations.
WABT accepting this malformed binary means that the extract-parts.sh
script shipped with the spec testsuite is incorrectly adding the module to the valid/
subdirectory.
I believe this was fixed in #1622