diff options
author | Ali Mohammad Pur <ali.mpfard@gmail.com> | 2022-10-24 03:19:20 +0330 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-10-24 15:54:20 +0200 |
commit | 21c6e4c257b438d9cb95d0b12dcb534210e8d9b1 (patch) | |
tree | 455c18fdbbfa49865a059562d609e7b275452034 | |
parent | 18e2bc635fe8f19483b781893fc77180181de1b6 (diff) | |
download | serenity-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.cpp | 2 |
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()) |