Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
disable internal memory (#7842)
Browse files Browse the repository at this point in the history
  • Loading branch information
NikVolf authored and 5chdn committed Feb 12, 2018
1 parent 78f39e9 commit fab0339
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions ethcore/wasm/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,20 @@ pub fn payload<'a>(params: &'a vm::ActionParams, schedule: &vm::Schedule)
},
};

let contract_module = wasm_utils::inject_gas_counter(
elements::Module::deserialize(
let deserialized_module = elements::Module::deserialize(
&mut cursor
).map_err(|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),
);

Expand Down

0 comments on commit fab0339

Please sign in to comment.