Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#### Upcoming Changes

* fix: Check overflow in cairo pie address calculation [#1945](https://github.com/lambdaclass/cairo-vm/pull/1945)

* fix(BREAKING): Fix no trace padding flow in proof mode [#1909](https://github.com/lambdaclass/cairo-vm/pull/1909)

* refactor: Limit ret opcode decodeing to Cairo0's standards. [#1925](https://github.com/lambdaclass/cairo-vm/pull/1925)
Expand Down
10 changes: 9 additions & 1 deletion vm/src/vm/runners/cairo_pie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,15 @@
let mut res = Vec::with_capacity(mem_cap);

for ((segment, offset), value) in values.iter() {
let mem_addr = ADDR_BASE + *segment as u64 * OFFSET_BASE + *offset as u64;
// mem_addr = ADDR_BASE + segment * OFFSET_BASE + offset
let mem_addr = (*segment as u64)
.checked_mul(OFFSET_BASE)
.and_then(|n| n.checked_add(ADDR_BASE))
.and_then(|n| n.checked_add(*offset as u64))
.ok_or_else(|| {
serde::ser::Error::custom("final memory address calculation overflowed")

Check warning on line 531 in vm/src/vm/runners/cairo_pie.rs

View check run for this annotation

Codecov / codecov/patch

vm/src/vm/runners/cairo_pie.rs#L531

Added line #L531 was not covered by tests
})?;

res.extend_from_slice(mem_addr.to_le_bytes().as_ref());
match value {
// Serializes RelocatableValue(little endian):
Expand Down
Loading