From 08849db00cca62b3886458665b0bf2952f42a9d5 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Tue, 30 May 2017 14:19:58 -0700 Subject: verify s-expr parsing of alignments --- src/wasm/wasm-s-parser.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (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 bff9232b8..60d424d7e 100644 --- a/src/wasm/wasm-s-parser.cpp +++ b/src/wasm/wasm-s-parser.cpp @@ -1143,7 +1143,9 @@ Expression* SExpressionWasmBuilder::makeLoad(Element& s, WasmType type) { if (!eq) throw ParseException("no = in load attribute"); eq++; if (str[0] == 'a') { - ret->align = atoi(eq); + uint64_t align = atoll(eq); + if (align > std::numeric_limits::max()) throw ParseException("bad align"); + ret->align = align; } else if (str[0] == 'o') { uint64_t offset = atoll(eq); if (offset > std::numeric_limits::max()) throw ParseException("bad offset"); @@ -1182,7 +1184,9 @@ Expression* SExpressionWasmBuilder::makeStore(Element& s, WasmType type) { if (!eq) throw ParseException("missing = in store attribute");; eq++; if (str[0] == 'a') { - ret->align = atoi(eq); + uint64_t align = atoll(eq); + if (align > std::numeric_limits::max()) throw ParseException("bad align"); + ret->align = align; } else if (str[0] == 'o') { ret->offset = atoi(eq); } else throw ParseException("bad store attribute"); -- cgit v1.2.3