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

WASM: Disable internal memory #7842

Merged
merged 1 commit into from
Feb 12, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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