Unchecked math operations #64
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")
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.
The text was updated successfully, but these errors were encountered: