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

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

Issue 2344853002: [wasm] Do proper bounds checking in the wasm interpreter for grow memory. (Closed)
Patch Set: Created 4 years, 3 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/cctest/wasm/test-run-wasm-interpreter.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/wasm/wasm-interpreter.cc
diff --git a/src/wasm/wasm-interpreter.cc b/src/wasm/wasm-interpreter.cc
index 94b385033d5110f94692c7fde2978eb63ed93f43..8c23bb2fd8872150f414fcec3e4bfd520b80ea0c 100644
--- a/src/wasm/wasm-interpreter.cc
+++ b/src/wasm/wasm-interpreter.cc
@@ -658,6 +658,9 @@ static inline int32_t ExecuteGrowMemory(uint32_t delta_pages,
WasmModuleInstance* instance) {
// TODO(ahaas): Move memory allocation to wasm-module.cc for better
// encapsulation.
+ if (delta_pages > wasm::WasmModule::kMaxMemPages) {
+ return -1;
+ }
uint32_t old_size = instance->mem_size;
uint32_t new_size;
byte* new_mem_start;
« no previous file with comments | « no previous file | test/cctest/wasm/test-run-wasm-interpreter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698