summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2017-07-05 15:43:43 -0700
committerGitHub <noreply@github.com>2017-07-05 15:43:43 -0700
commitcd2a431004aa2e165722ff0b85aeece5b32da140 (patch)
tree0a7e6178f5ec3dc43e1e6f723d5e9ff28d13bc8e
parent2d289c32cc66c8c289f0b5285d26d4c4240c5ecd (diff)
downloadbinaryen-cd2a431004aa2e165722ff0b85aeece5b32da140.tar.gz
binaryen-cd2a431004aa2e165722ff0b85aeece5b32da140.tar.bz2
binaryen-cd2a431004aa2e165722ff0b85aeece5b32da140.zip
show a clear error on nulls in inline strings in binary format (#1068)
* show a clear error on nulls in inline strings (which we don't support, and in general are not seen in practice, but are technically valid wasm) in binary format reading
-rw-r--r--src/wasm/wasm-binary.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp
index e44f9fb83..4844dd5b4 100644
--- a/src/wasm/wasm-binary.cpp
+++ b/src/wasm/wasm-binary.cpp
@@ -1241,7 +1241,11 @@ Name WasmBinaryBuilder::getInlineString() {
auto len = getU32LEB();
std::string str;
for (size_t i = 0; i < len; i++) {
- str = str + char(getInt8());
+ auto curr = char(getInt8());
+ if (curr == 0) {
+ throw ParseException("inline string contains NULL (0). that is technically valid in wasm, but you shouldn't do it, and it's not supported in binaryen");
+ }
+ str = str + curr;
}
if (debug) std::cerr << "getInlineString: " << str << " ==>" << std::endl;
return Name(str);