Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix panic when Wasm input is too large #218

Merged
merged 2 commits into from
Feb 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lib/src/executor/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,15 @@ impl HostVmPrototype {
}
};

// While the allocator has reserved memory, it might have reserved more memory than its
// current size.
if let Some(to_grow) = ((data_ptr + data_len_u32).saturating_sub(1) / (64 * 1024) + 1)
.checked_sub(u32::from(vm.memory_size()))
{
// If the memory can't be grown, it indicates a bug in the allocator.
vm.grow_memory(HeapPages::from(to_grow)).unwrap();
}

// Writing the input data into the VM.
let mut data_ptr_iter = data_ptr;
for data in data {
Expand Down
4 changes: 4 additions & 0 deletions wasm-node/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

## Fixed

- Fix panic when the input data of a Wasm function call is larger than a Wasm page. ([#218](https://github.com/smol-dot/smoldot/pull/218))

## 0.7.12 - 2022-02-22

### Changed
Expand Down