diff --git a/Cargo.toml b/Cargo.toml index 8dee946..781ef64 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ exclude = [ "/res/*", "/tests/*", "/fuzz/*", "/benches/*" ] [dependencies] wasmi-validation = { version = "0.1", path = "validation", default-features = false } -parity-wasm = { version = "0.31", default-features = false } +parity-wasm = { version = "0.39", default-features = false } memory_units = "0.3.0" libm = { version = "0.1.2", optional = true } num-rational = "0.2.2" diff --git a/src/module.rs b/src/module.rs index 493cf30..80526ed 100644 --- a/src/module.rs +++ b/src/module.rs @@ -421,7 +421,11 @@ impl ModuleInstance { .map(|es| es.entries()) .unwrap_or(&[]) { - let offset_val = match eval_init_expr(element_segment.offset(), &module_ref) { + let offset = element_segment + .offset() + .as_ref() + .expect("passive segments are rejected due to validation"); + let offset_val = match eval_init_expr(offset, &module_ref) { RuntimeValue::I32(v) => v as u32, _ => panic!("Due to validation elem segment offset should evaluate to i32"), }; @@ -450,7 +454,11 @@ impl ModuleInstance { } for data_segment in module.data_section().map(|ds| ds.entries()).unwrap_or(&[]) { - let offset_val = match eval_init_expr(data_segment.offset(), &module_ref) { + let offset = data_segment + .offset() + .as_ref() + .expect("passive segments are rejected due to validation"); + let offset_val = match eval_init_expr(offset, &module_ref) { RuntimeValue::I32(v) => v as u32, _ => panic!("Due to validation data segment offset should evaluate to i32"), }; diff --git a/src/prepare/compile.rs b/src/prepare/compile.rs index 233ea65..cf33a7e 100644 --- a/src/prepare/compile.rs +++ b/src/prepare/compile.rs @@ -251,13 +251,14 @@ impl Compiler { ); self.sink.emit_br_nez(target); } - BrTable(ref table, default) => { + BrTable(ref br_table_data) => { // At this point, the condition value is at the top of the stack. // But at the point of actual jump the condition will already be // popped off. let value_stack_height = context.value_stack.len().saturating_sub(1); - let targets = table + let targets = br_table_data + .table .iter() .map(|depth| { require_target( @@ -269,7 +270,7 @@ impl Compiler { }) .collect::, _>>(); let default_target = require_target( - default, + br_table_data.default, value_stack_height, &context.frame_stack, &self.label_stack, diff --git a/validation/Cargo.toml b/validation/Cargo.toml index 55f0367..d2f0571 100644 --- a/validation/Cargo.toml +++ b/validation/Cargo.toml @@ -8,7 +8,7 @@ repository = "https://github.com/paritytech/wasmi" description = "Wasm code validator" [dependencies] -parity-wasm = { version = "0.31", default-features = false } +parity-wasm = { version = "0.39", default-features = false } [dev-dependencies] assert_matches = "1.1" diff --git a/validation/src/func.rs b/validation/src/func.rs index 654bdbd..8516942 100644 --- a/validation/src/func.rs +++ b/validation/src/func.rs @@ -266,8 +266,8 @@ impl<'a> FunctionValidationContext<'a> { BrIf(depth) => { self.validate_br_if(depth)?; } - BrTable(ref table, default) => { - self.validate_br_table(table, default)?; + BrTable(ref br_table_data) => { + self.validate_br_table(&*br_table_data.table, br_table_data.default)?; make_top_frame_polymorphic(&mut self.value_stack, &mut self.frame_stack); } Return => { diff --git a/validation/src/lib.rs b/validation/src/lib.rs index 72e9ef7..9a93f63 100644 --- a/validation/src/lib.rs +++ b/validation/src/lib.rs @@ -319,7 +319,11 @@ pub fn validate_module(module: &Module) -> Result(module: &Module) -> Result