A lightweight WebAssembly runtime that is fast, secure, and standards-compliant
component(err-ctx): trap on a misaligned pointer (#14626)
Roman Volosatovsa8d33e523206
diff --git a/crates/wasmtime/src/runtime/component/concurrent/futures_and_streams.rs b/crates/wasmtime/src/runtime/component/concurrent/futures_and_streams.rsindex bd83bb388e..faed6fea09 100644--- a/crates/wasmtime/src/runtime/component/concurrent/futures_and_streams.rs+++ b/crates/wasmtime/src/runtime/component/concurrent/futures_and_streams.rs@@ -4389,6 +4389,9 @@ impl Instance {let lower_cx = &mut LowerContext::new(store, options, self);let debug_msg_address = usize::try_from(debug_msg_address)?;+ if debug_msg_address % usize::try_from(<str as ComponentType>::ALIGN32)? != 0 {+ bail!("invalid debug message pointer: not aligned");+ }// Lower the string into the component's memory.//// Note that the "8" here is the size of a WIT `string` in lineardiff --git a/tests/misc_testsuite/component-model/async/error-context.wast b/tests/misc_testsuite/component-model/async/error-context.wastindex 217ed80260..17310c46a3 100644--- a/tests/misc_testsuite/component-model/async/error-context.wast+++ b/tests/misc_testsuite/component-model/async/error-context.wast@@ -84,3 +84,9 @@(component instance $A $A)(assert_return (invoke "run" (u32.const 65528)))(assert_trap (invoke "run" (u32.const 65532)) "invalid debug message pointer")++(component instance $A2 $A)+(assert_trap (invoke "run" (u32.const 1)) "invalid debug message pointer: not aligned")++(component instance $A3 $A)+(assert_trap (invoke "run" (u32.const 65526)) "invalid debug message pointer: not aligned")