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

Unchecked math operations #64

Closed
code423n4 opened this issue Oct 18, 2021 · 4 comments
Closed

Unchecked math operations #64

code423n4 opened this issue Oct 18, 2021 · 4 comments
Assignees
Labels
bug Warden finding duplicate Another warden found this issue G (Gas Optimization) resolved Finding has been patched by sponsor (sponsor pls link to PR containing fix) sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")

Comments

@code423n4
Copy link
Contributor

Handle

pauliax

Vulnerability details

Impact

You can use the 'unchecked' keyword to avoid redundant arithmetic checks to save gas when an underflow/overflow cannot happen. E.g. unchecked can be applied here:
require(sig.length >= 1, "SignatureValidator: basic sig len");
uint8 modeRaw = uint8(sig[sig.length - 1]);

or here:
require(sig.length > 33, "SignatureValidator: wallet sig len");

IERC1271Wallet wallet = IERC1271Wallet(address(uint160(uint256(sig.readBytes32(sig.length - 33)))));
sig.trimToSize(sig.length - 33);

Recommended Mitigation Steps

Consider applying unchecked keyword where it can't overflow/underflow.

code423n4 added a commit that referenced this issue Oct 18, 2021
@Ivshti Ivshti added the sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity") label Oct 19, 2021
@Ivshti
Copy link
Member

Ivshti commented Oct 19, 2021

good optimization, thanks!

@Ivshti
Copy link
Member

Ivshti commented Oct 19, 2021

may be a partial duplicate of #46 and #22

@Ivshti Ivshti added the duplicate Another warden found this issue label Oct 19, 2021
@Ivshti Ivshti self-assigned this Oct 19, 2021
@Ivshti
Copy link
Member

Ivshti commented Oct 21, 2021

@Ivshti Ivshti added the resolved Finding has been patched by sponsor (sponsor pls link to PR containing fix) label Oct 21, 2021
@GalloDaSballo
Copy link
Collaborator

Duplicate of #46

@GalloDaSballo GalloDaSballo marked this as a duplicate of #46 Oct 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Warden finding duplicate Another warden found this issue G (Gas Optimization) resolved Finding has been patched by sponsor (sponsor pls link to PR containing fix) sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Projects
None yet
Development

No branches or pull requests

3 participants