From 21c6e4c257b438d9cb95d0b12dcb534210e8d9b1 Mon Sep 17 00:00:00 2001 From: Ali Mohammad Pur Date: Mon, 24 Oct 2022 03:19:20 +0330 Subject: [PATCH] LibWasm: Calculate the max data segment size correctly This is given in pages, we need to first convert to bytes before comparing with bytes. --- Userland/Libraries/LibWasm/AbstractMachine/AbstractMachine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Userland/Libraries/LibWasm/AbstractMachine/AbstractMachine.cpp b/Userland/Libraries/LibWasm/AbstractMachine/AbstractMachine.cpp index 49d8abc741..5c991e68f9 100644 --- a/Userland/Libraries/LibWasm/AbstractMachine/AbstractMachine.cpp +++ b/Userland/Libraries/LibWasm/AbstractMachine/AbstractMachine.cpp @@ -345,7 +345,7 @@ InstantiationResult AbstractMachine::instantiate(Module const& module, Vectortype().limits().max(); max.has_value()) { - if (*max < data.init.size() + offset) { + if (*max * Constants::page_size < data.init.size() + offset) { instantiation_result = InstantiationError { String::formatted("Data segment attempted to write to out-of-bounds memory ({}) of max {} bytes", data.init.size() + offset, instance->type().limits().max().value())