Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(854)

Unified Diff: src/wasm/wasm-js.cc

Issue 2705233002: [wasm] Enforce module size limit early enough (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/mjsunit/regress/wasm/regression-694433.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/wasm/wasm-js.cc
diff --git a/src/wasm/wasm-js.cc b/src/wasm/wasm-js.cc
index a3a42cdc99f7af64952099a2b21cc9c839f7f6f8..eea0e756fde377bda7ea38dc307dfdddb176c243 100644
--- a/src/wasm/wasm-js.cc
+++ b/src/wasm/wasm-js.cc
@@ -151,6 +151,13 @@ i::wasm::ModuleWireBytes GetFirstArgumentAsBytes(
if (start == nullptr || end == start) {
thrower->CompileError("BufferSource argument is empty");
}
+ if (end - start > static_cast<ssize_t>(i::wasm::kV8MaxWasmModuleSize)) {
+ thrower->RangeError("buffer source exceeds maximum size of %" PRId64
+ " (is %" PRId64 ")",
+ static_cast<int64_t>(i::wasm::kV8MaxWasmModuleSize),
titzer 2017/02/21 15:10:22 for size_t you can use %zu as the format string.
Clemens Hammacher 2017/02/21 17:48:16 Done.
+ static_cast<int64_t>(end - start));
+ }
+ if (thrower->error()) return i::wasm::ModuleWireBytes(nullptr, nullptr);
// TODO(titzer): use the handle as well?
return i::wasm::ModuleWireBytes(start, end);
}
« no previous file with comments | « no previous file | test/mjsunit/regress/wasm/regression-694433.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698