summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAli Mohammad Pur <ali.mpfard@gmail.com>2022-10-24 03:19:20 +0330
committerLinus Groh <mail@linusgroh.de>2022-10-24 15:54:20 +0200
commit21c6e4c257b438d9cb95d0b12dcb534210e8d9b1 (patch)
tree455c18fdbbfa49865a059562d609e7b275452034
parent18e2bc635fe8f19483b781893fc77180181de1b6 (diff)
downloadserenity-21c6e4c257b438d9cb95d0b12dcb534210e8d9b1.zip
LibWasm: Calculate the max data segment size correctly
This is given in pages, we need to first convert to bytes before comparing with bytes.
-rw-r--r--Userland/Libraries/LibWasm/AbstractMachine/AbstractMachine.cpp2
1 files changed, 1 insertions, 1 deletions
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, Vector<Ex
auto address = main_module_instance.memories()[data.index.value()];
if (auto instance = m_store.get(address)) {
if (auto max = instance->type().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())