Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

Fix LibFixedMath arithmetic overflows #2255

Merged

Conversation

dorothy-zbornak
Copy link
Contributor

@dorothy-zbornak dorothy-zbornak commented Oct 10, 2019

Description

This PR addresses arithmetic overflows in the staking contracts' LibFixedMath library.

Checks were added to:

  • sub()
  • _add()
  • _mul()
  • _div()

The preliminary audit did uncover the majority of these overflows but the limits in the report were wrong, and I found some other edge cases. So the checks differ from those suggested the report.

I also removed the fixed math BinOpErrorCodes.SubtractionUnderflow error code, since I didn't feel the distinction is all that useful in practice since it's just implemented as a negated addition.

Fixes 0xProject/protocol-development-sprint#4

Testing instructions

Types of changes

Checklist:

  • Prefix PR title with [WIP] if necessary.
  • Add tests to cover changes as needed.
  • Update documentation as needed.
  • Add new entries to the relevant CHANGELOG.jsons.

@dorothy-zbornak dorothy-zbornak marked this pull request as ready for review October 10, 2019 01:07
Copy link
Contributor

@jalextowle jalextowle 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 to me!

@dorothy-zbornak dorothy-zbornak merged commit 9f6d113 into 3.0 Oct 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants