Truly independent web browser
LibWasm: Verify that exception payloads fit their tags
Andreas Kling867a9aafbd2d
diff --git a/Libraries/LibWasm/Engine/src/runtime/gc.rs b/Libraries/LibWasm/Engine/src/runtime/gc.rsindex e2e94fd5e12..ec42f93577a 100644--- a/Libraries/LibWasm/Engine/src/runtime/gc.rs+++ b/Libraries/LibWasm/Engine/src/runtime/gc.rs@@ -426,6 +426,12 @@ impl Store {traces.push(trace_of(param, &self.types));traces.extend(std::iter::repeat_n(TRACE_NONE, param.slot_count() as usize - 1));}+ // NB: The collector follows the payload and frees it as long as the tag's parameters say it is.+ assert_eq!(+ payload.len(),+ traces.len(),+ "an exception's payload has the slots of its tag's parameters"+ );allocate_exception(&self.heap, tag, payload, &traces)}diff --git a/Libraries/LibWasm/Engine/src/runtime/mod.rs b/Libraries/LibWasm/Engine/src/runtime/mod.rsindex c9c5269db07..b22ee3cd69b 100644--- a/Libraries/LibWasm/Engine/src/runtime/mod.rs+++ b/Libraries/LibWasm/Engine/src/runtime/mod.rs@@ -1096,6 +1096,10 @@ impl Store {/// Allocate an exception with the tag `tag` that carries `values`, one for each parameter of the tag's type.pub fn allocate_exception_with_values(&mut self, tag: TagAddress, values: &[Value]) -> u64 {+ assert!(+ values_match(values, &self.tag(tag).ty.params),+ "an exception carries values of its tag's parameter types"+ );// An exception's slots are in operand stack order, the last value first.let mut payload = Vec::new();for value in values.iter().rev() {