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

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

Issue 2486183002: [wasm] Fix bounds check in LoadDataSegments. (Closed)
Patch Set: Created 4 years, 1 month 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/cctest/wasm/test-run-wasm-module.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/wasm/wasm-module.cc
diff --git a/src/wasm/wasm-module.cc b/src/wasm/wasm-module.cc
index 5b4b8e0f2895bab32b4e6402663e9b1bf7ae7157..179af57ac6d626c06d0fc315d2aa38826b37892b 100644
--- a/src/wasm/wasm-module.cc
+++ b/src/wasm/wasm-module.cc
@@ -1366,8 +1366,12 @@ class WasmInstanceBuilder {
uint32_t dest_offset = EvalUint32InitExpr(segment.dest_addr);
uint32_t source_size = segment.source_size;
if (dest_offset >= mem_size || source_size >= mem_size ||
- dest_offset >= (mem_size - source_size)) {
- thrower_->RangeError("data segment does not fit into memory");
+ dest_offset > (mem_size - source_size)) {
+ thrower_->RangeError(
+ "data segment (start = %u, size = %u) does not fit into memory "
+ "(size = %zu)",
+ dest_offset, source_size, mem_size);
+ return;
}
byte* dest = mem_addr + dest_offset;
const byte* src = reinterpret_cast<const byte*>(
« no previous file with comments | « no previous file | test/cctest/wasm/test-run-wasm-module.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698