contracts: Prevent contracts from allocating a too large buffer (#7818)

* Prevent contracts from allocating a too large buffer

* Fix possible integer overflow
This commit is contained in:
Alexander Theißen
2021-01-05 09:06:44 +01:00
committed by GitHub
parent fd24f66c76
commit 031b4ddabb
2 changed files with 23 additions and 11 deletions
@@ -110,6 +110,13 @@ pub struct Limits {
pub code_size: u32,
}
impl Limits {
/// The maximum memory size in bytes that a contract can occupy.
pub fn max_memory_size(&self) -> u32 {
self.memory_pages * 64 * 1024
}
}
/// Describes the weight for all categories of supported wasm instructions.
///
/// There there is one field for each wasm instruction that describes the weight to