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");
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.