Skip to content

Commit 2d6cbad

Browse files
committed
Use validate_region in get_region
1 parent fb59f4d commit 2d6cbad

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
value.
1616
- Increase the max. supported value for gas limit from 10_000_000_000 to
1717
0x7FFFFFFFFFFFFFFF.
18+
- Add checks to `get_region` for failing early when the contract sends a Region
19+
pointer to the VM that is not backed by a plausible Region. This helps
20+
development of standard libraries.
1821

1922
## 0.9.3 (2020-07-08)
2023

packages/vm/src/memory.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,11 @@ fn get_region(ctx: &Ctx, ptr: u32) -> CommunicationResult<Region> {
137137
let memory = ctx.memory(0);
138138
let wptr = WasmPtr::<Region>::new(ptr);
139139
match wptr.deref(memory) {
140-
Some(cell) => Ok(cell.get()),
140+
Some(cell) => {
141+
let region = cell.get();
142+
validate_region(&region)?;
143+
Ok(region)
144+
}
141145
None => Err(CommunicationError::deref_err(
142146
ptr,
143147
"Could not dereference this pointer to a Region",

0 commit comments

Comments
 (0)