Skip to content

Commit

Permalink
Use validate_region in get_region
Browse files Browse the repository at this point in the history
  • Loading branch information
webmaster128 committed Jul 14, 2020
1 parent fb59f4d commit 2d6cbad
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
value.
- Increase the max. supported value for gas limit from 10_000_000_000 to
0x7FFFFFFFFFFFFFFF.
- Add checks to `get_region` for failing early when the contract sends a Region
pointer to the VM that is not backed by a plausible Region. This helps
development of standard libraries.

## 0.9.3 (2020-07-08)

Expand Down
6 changes: 5 additions & 1 deletion packages/vm/src/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,11 @@ fn get_region(ctx: &Ctx, ptr: u32) -> CommunicationResult<Region> {
let memory = ctx.memory(0);
let wptr = WasmPtr::<Region>::new(ptr);
match wptr.deref(memory) {
Some(cell) => Ok(cell.get()),
Some(cell) => {
let region = cell.get();
validate_region(&region)?;
Ok(region)
}
None => Err(CommunicationError::deref_err(
ptr,
"Could not dereference this pointer to a Region",
Expand Down

0 comments on commit 2d6cbad

Please sign in to comment.