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

Mark Packed64x4.sol as Unsafe or Deprecated #833

Open
tamtamchik opened this issue Apr 17, 2024 · 1 comment
Open

Mark Packed64x4.sol as Unsafe or Deprecated #833

tamtamchik opened this issue Apr 17, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@tamtamchik
Copy link
Member

tamtamchik commented Apr 17, 2024

While covering libs with test in the core repo, I stumbled upon some wired behavior of the contracts/0.4.24/lib/Packed64x4.sol's set function.

Passing an invalid n (n > 3) in the set function can lead to unexpected behavior.

  • In HardHat tests calling set(4,5) leads to rewriting value for the first spot, so calling get(0) returns 5 instead of the original value.
  • In Foundry tests it just errors with: Error occurred: invalid opcode

There are no invalid usages inside the current codebase, so no worries 😉

But it is better not to use this library in new contracts as is.
Or at least add a require(n < 4, "OFFSET_OUT_OF_RANGE"); check to the set function.

@TheDZhon TheDZhon added the bug Something isn't working label Apr 17, 2024
@Narendra-Reddy1
Copy link

@tamtamchik @TheDZhon I'm working on this issue. Could you assign it to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants