Skip to content

A lightweight WebAssembly runtime that is fast, secure, and standards-compliant

Validate map pointer/length before allocating when lifting (#14835)

Randolf J.1befdc522f0c
diff --git a/crates/wasmtime/src/runtime/component/func/typed.rs b/crates/wasmtime/src/runtime/component/func/typed.rs
index a09c503a29..e936d0f143 100644
--- a/crates/wasmtime/src/runtime/component/func/typed.rs
+++ b/crates/wasmtime/src/runtime/component/func/typed.rs
@@ -2154,8 +2154,6 @@ where
K: Lift + Eq + Hash,
V: Lift,
{
- let mut result = TryHashMap::with_capacity(len)?;
-
match len
.checked_mul(usize::try_from(map.entry_abi.size32)?)
.and_then(|total| ptr.checked_add(total))
@@ -2167,6 +2165,7 @@ where
bail!("map pointer is not aligned");
}
+ let mut result = TryHashMap::with_capacity(len)?;
for i in 0..len {
let entry_base = ptr + (i * usize::try_from(map.entry_abi.size32)?);