mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-10 14:48:27 +00:00
Check memory offset calculation overflow.
This commit is contained in:
@@ -1280,9 +1280,7 @@ impl<'a> FuncGen<'a> {
|
|||||||
Location::Imm32(memarg.offset),
|
Location::Imm32(memarg.offset),
|
||||||
Location::GPR(tmp_addr),
|
Location::GPR(tmp_addr),
|
||||||
);
|
);
|
||||||
self.assembler
|
// Overflow is checked outside the `need_check` block, so we don't need to check it here.
|
||||||
.emit_jmp(Condition::Carry, self.special_labels.heap_access_oob);
|
|
||||||
// unsigned overflow
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Trap if the start address of the requested area is equal to or above that of the linear memory.
|
// Trap if the start address of the requested area is equal to or above that of the linear memory.
|
||||||
@@ -1320,6 +1318,10 @@ impl<'a> FuncGen<'a> {
|
|||||||
Location::Imm32(memarg.offset as u32),
|
Location::Imm32(memarg.offset as u32),
|
||||||
Location::GPR(tmp_addr),
|
Location::GPR(tmp_addr),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Trap if offset calculation overflowed.
|
||||||
|
self.assembler
|
||||||
|
.emit_jmp(Condition::Carry, self.special_labels.heap_access_oob);
|
||||||
}
|
}
|
||||||
self.assembler
|
self.assembler
|
||||||
.emit_add(Size::S64, Location::GPR(tmp_base), Location::GPR(tmp_addr));
|
.emit_add(Size::S64, Location::GPR(tmp_base), Location::GPR(tmp_addr));
|
||||||
|
|||||||
Reference in New Issue
Block a user