summaryrefslogtreecommitdiff
path: root/src/wasm/wasm-s-parser.cpp
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2019-01-22 17:15:37 -0800
committerGitHub <noreply@github.com>2019-01-22 17:15:37 -0800
commite63c4a7d04c145dafaf4b09de5f9f5de69cee8ef (patch)
treead8cbf7bd25c2fb9928032955b3fc8ba46033a43 /src/wasm/wasm-s-parser.cpp
parent0e5e55053c171b138a0cf5aa8a08de8c7714048f (diff)
downloadbinaryen-e63c4a7d04c145dafaf4b09de5f9f5de69cee8ef.tar.gz
binaryen-e63c4a7d04c145dafaf4b09de5f9f5de69cee8ef.tar.bz2
binaryen-e63c4a7d04c145dafaf4b09de5f9f5de69cee8ef.zip
More misc ASAN fixes (#1882)
* fix buffer overflow in simple_ast.h printing. * check wasm binary format reading of function export indexes for errors. * check if s-expr format imports have a non-empty module and base. Fixes #1876 Fixes #1877 Fixes #1879
Diffstat (limited to 'src/wasm/wasm-s-parser.cpp')
-rw-r--r--src/wasm/wasm-s-parser.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/wasm/wasm-s-parser.cpp b/src/wasm/wasm-s-parser.cpp
index fe622f54a..eca4c7493 100644
--- a/src/wasm/wasm-s-parser.cpp
+++ b/src/wasm/wasm-s-parser.cpp
@@ -580,6 +580,7 @@ void SExpressionWasmBuilder::parseFunction(Element& s, bool preParseImport) {
}
if (importModule.is()) {
// this is an import, actually
+ if (!importBase.size()) throw ParseException("module but no base for import");
if (!preParseImport) throw ParseException("!preParseImport in func");
auto im = make_unique<Function>();
im->name = name;
@@ -1571,6 +1572,7 @@ void SExpressionWasmBuilder::parseImport(Element& s) {
auto module = s[i++]->str();
if (!s[i]->isStr()) throw ParseException("no name for import");
auto base = s[i++]->str();
+ if (!module.size() || !base.size()) throw ParseException("imports must have module and base");
// parse internals
Element& inner = newStyle ? *s[3] : s;
Index j = newStyle ? newStyleInner : i;
@@ -1694,6 +1696,7 @@ void SExpressionWasmBuilder::parseGlobal(Element& s, bool preParseImport) {
}
if (importModule.is()) {
// this is an import, actually
+ if (!importBase.size()) throw ParseException("module but no base for import");
if (!preParseImport) throw ParseException("!preParseImport in global");
auto im = make_unique<Global>();
im->name = global->name;