Skip to content

Conversation

@Jrigada
Copy link
Contributor

@Jrigada Jrigada commented Feb 1, 2023

Check capacity of vector before resizing

Description

PR to solve the issue reported by Patrick from Fuzzing Labs
#798

Description of the pull request changes and motivation.

Checklist

  • Linked to Github Issue
  • Unit tests added
  • Integration tests added.
  • This change requires new documentation.
    • Documentation has been added/updated.

//Forgoing this check would allow data to be inserted in a different index

if segment.len() <= value_offset {
if (segment.capacity() + value_offset + 1) * mem::size_of::<MaybeRelocatable>()
Copy link
Contributor

Choose a reason for hiding this comment

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

This will overflow if the condition is true. I'm personally not sure it's valuable to catch this case, and certainly I don't think this is the proper place to fix it. Instead, we should make sure offsets in relocatables don't exceed 47 bits, which is how big they're specified to be.

Copy link
Contributor

@fmoletta fmoletta Feb 2, 2023

Choose a reason for hiding this comment

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

+ 1

Copy link
Contributor

Choose a reason for hiding this comment

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

I'll fix this by using try_reserve in a different PR. It should be cleaner and more robust, while also avoiding other possible points of failure (it might still fail to allocate and panic as it's implemented).
I'll refer to this PR and close it when ready.

@Jrigada Jrigada marked this pull request as draft February 13, 2023 10:49
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.

4 participants