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

Revert with proper panic if array index out of bounds #606

Merged

Conversation

cburgdorf
Copy link
Collaborator

@cburgdorf cburgdorf commented Dec 9, 2021

What was wrong?

We do not yet revert with a proper Panic(0x32) when trying to access an array item that is not within the bounds of the array.

How was it fixed?

  • Added a get_array_item function that handles the check and used it in the indexed_array operation
  • Added tests

@cburgdorf cburgdorf force-pushed the christoph/feat/array-out-of-bounds-check branch from 8c41d75 to 1545487 Compare December 9, 2021 12:50

/// Returns a pointer to the array item at the requested index.
/// Reverts with a panic if the index is out of bounds.
pub fn get_array_item() -> yul::Statement {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I realize that this might eventually be handled at Fe level (std lib) but it is small enough to add now and is preventing me from adding further differential contract fuzzing tests as this comes up quite frequently when fuzzing with arrays involved.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Don't hesitate to add yul utility functions; it'll be a while before everything can be fe-ified.

Copy link
Collaborator

@sbillig sbillig left a comment

Choose a reason for hiding this comment

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

👍


/// Returns a pointer to the array item at the requested index.
/// Reverts with a panic if the index is out of bounds.
pub fn get_array_item() -> yul::Statement {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Don't hesitate to add yul utility functions; it'll be a while before everything can be fe-ified.

@sbillig sbillig merged commit ada8827 into ethereum:master Dec 11, 2021
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