Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(levm): avoid overflow in calldataload #1461

Merged
merged 4 commits into from
Dec 10, 2024
Merged

fix(levm): avoid overflow in calldataload #1461

merged 4 commits into from
Dec 10, 2024

Conversation

lima-limon-inc
Copy link
Contributor

If the offset is larger than calldata, then there is no data to show. Return 0 to the stack

Motivation
The calldata operand tried to cast the value it got as an argument to usize everytime. However, that number could be larger than usize and an error is raised.

Description
This tries to check the offset value before casting it to usize. If the offset value (in U256) is larger than the actual length of contents of the calldata (also in U256), then we simply return 0 (since the offset would've removed all the values from calldata).

If the offset is larger than calldata, then there is no data to
show. Return 0 to the stack
This error is changed because this casting should never fail;
therefore if this ever fails, we want to treat it differently from a
"normal" VeryLargeNumber error

Suggested-by: Jeremias Salomon <jeremias.salomon@lambdaclass.com>
@lima-limon-inc lima-limon-inc marked this pull request as ready for review December 10, 2024 21:12
@lima-limon-inc lima-limon-inc requested a review from a team as a code owner December 10, 2024 21:12
Copy link
Contributor

@JereSalo JereSalo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@JereSalo JereSalo added this pull request to the merge queue Dec 10, 2024
Merged via the queue into main with commit 6959e76 Dec 10, 2024
4 checks passed
@JereSalo JereSalo deleted the fix/levm/stRandom branch December 10, 2024 22:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants