From e63c4a7d04c145dafaf4b09de5f9f5de69cee8ef Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Tue, 22 Jan 2019 17:15:37 -0800 Subject: 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 --- src/wasm/wasm-s-parser.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/wasm/wasm-s-parser.cpp') 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(); 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(); im->name = global->name; -- cgit v1.2.3