diff options
author | Alon Zakai <alonzakai@gmail.com> | 2017-05-30 14:19:58 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2017-06-01 13:17:44 -0700 |
commit | 08849db00cca62b3886458665b0bf2952f42a9d5 (patch) | |
tree | 5759b249fe3bdbc24682fb94c58a07f7be41e69d /src | |
parent | 2ce31515cbb0953344dd5d67cfadb718a9abc8d8 (diff) | |
download | binaryen-08849db00cca62b3886458665b0bf2952f42a9d5.tar.gz binaryen-08849db00cca62b3886458665b0bf2952f42a9d5.tar.bz2 binaryen-08849db00cca62b3886458665b0bf2952f42a9d5.zip |
verify s-expr parsing of alignments
Diffstat (limited to 'src')
-rw-r--r-- | src/wasm/wasm-s-parser.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
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<uint32_t>::max()) throw ParseException("bad align"); + ret->align = align; } else if (str[0] == 'o') { uint64_t offset = atoll(eq); if (offset > std::numeric_limits<uint32_t>::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<uint32_t>::max()) throw ParseException("bad align"); + ret->align = align; } else if (str[0] == 'o') { ret->offset = atoi(eq); } else throw ParseException("bad store attribute"); |