فهرست منبع

LibWasm: Calculate the max data segment size correctly

This is given in pages, we need to first convert to bytes before
comparing with bytes.
Ali Mohammad Pur 2 سال پیش
والد
کامیت
21c6e4c257
1فایلهای تغییر یافته به همراه1 افزوده شده و 1 حذف شده
  1. 1 1
      Userland/Libraries/LibWasm/AbstractMachine/AbstractMachine.cpp

+ 1 - 1
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()];
                     auto address = main_module_instance.memories()[data.index.value()];
                     if (auto instance = m_store.get(address)) {
                     if (auto instance = m_store.get(address)) {
                         if (auto max = instance->type().limits().max(); max.has_value()) {
                         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 {
                                 instantiation_result = InstantiationError {
                                     String::formatted("Data segment attempted to write to out-of-bounds memory ({}) of max {} bytes",
                                     String::formatted("Data segment attempted to write to out-of-bounds memory ({}) of max {} bytes",
                                         data.init.size() + offset, instance->type().limits().max().value())
                                         data.init.size() + offset, instance->type().limits().max().value())