mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-17 23:12:22 +00:00
LibWasm: Check data section offset for overflow during instantiation
This commit is contained in:
parent
28d4e326f8
commit
bd6ee060d2
Notes:
sideshowbarker
2024-07-17 20:19:08 +09:00
Author: https://github.com/dzfrias
Commit: bd6ee060d2
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/97
1 changed files with 3 additions and 1 deletions
|
@ -345,7 +345,9 @@ InstantiationResult AbstractMachine::instantiate(Module const& module, Vector<Ex
|
|||
return;
|
||||
auto address = main_module_instance.memories()[data.index.value()];
|
||||
auto instance = m_store.get(address);
|
||||
if (data.init.size() + offset > instance->size()) {
|
||||
Checked<size_t> checked_offset = data.init.size();
|
||||
checked_offset += offset;
|
||||
if (checked_offset.has_overflow() || checked_offset > instance->size()) {
|
||||
instantiation_result = InstantiationError {
|
||||
ByteString::formatted("Data segment attempted to write to out-of-bounds memory ({}) in memory of size {}",
|
||||
offset, instance->size())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue