disable internal memory (#7842)

This commit is contained in:
Nikolay Volf 2018-02-12 13:19:43 +03:00 committed by Afri Schoedon
parent 78f39e9090
commit fab03398dd

View File

@ -56,12 +56,20 @@ pub fn payload<'a>(params: &'a vm::ActionParams, schedule: &vm::Schedule)
}, },
}; };
let contract_module = wasm_utils::inject_gas_counter( let deserialized_module = elements::Module::deserialize(
elements::Module::deserialize(
&mut cursor &mut cursor
).map_err(|err| { ).map_err(|err| {
vm::Error::Wasm(format!("Error deserializing contract code ({:?})", err)) vm::Error::Wasm(format!("Error deserializing contract code ({:?})", err))
})?, })?;
if deserialized_module.memory_section().map_or(false, |ms| ms.entries().len() > 0) {
// According to WebAssembly spec, internal memory is hidden from embedder and should not
// be interacted with. So we disable this kind of modules at decoding level.
return Err(vm::Error::Wasm(format!("Malformed wasm module: internal memory")));
}
let contract_module = wasm_utils::inject_gas_counter(
deserialized_module,
&gas_rules(schedule), &gas_rules(schedule),
); );