Skip to content

Commit

Permalink
Fix N-20
Browse files Browse the repository at this point in the history
  • Loading branch information
ernestognw committed Aug 2, 2023
1 parent 19250f7 commit 94a3d2a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
12 changes: 6 additions & 6 deletions contracts/metatx/ERC2771Forwarder.sol
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ contract ERC2771Forwarder is EIP712, Nonces {
* receiver is provided.
*/
function verify(ForwardRequestData calldata request) public view virtual returns (bool) {
(bool alive, bool signerMatch, ) = _validate(request);
return alive && signerMatch;
(bool unexpired, bool signerMatch, ) = _validate(request);
return unexpired && signerMatch;
}

/**
Expand Down Expand Up @@ -196,7 +196,7 @@ contract ERC2771Forwarder is EIP712, Nonces {
*/
function _validate(
ForwardRequestData calldata request
) internal view virtual returns (bool alive, bool signerMatch, address signer) {
) internal view virtual returns (bool unexpired, bool signerMatch, address signer) {
(address recovered, bool isValid) = _recoverForwardRequestSigner(request);
return (isValid && request.deadline >= block.timestamp, recovered == request.from, recovered);
}
Expand Down Expand Up @@ -247,12 +247,12 @@ contract ERC2771Forwarder is EIP712, Nonces {
ForwardRequestData calldata request,
bool requireValidRequest
) internal virtual returns (bool success) {
(bool alive, bool signerMatch, address signer) = _validate(request);
(bool unexpired, bool signerMatch, address signer) = _validate(request);

// Need to explicitly specify if a revert is required since non-reverting is default for
// batches and reversion is opt-in since it could be useful in some scenarios
if (requireValidRequest) {
if (!alive) {
if (!unexpired) {
revert ERC2771ForwarderExpiredRequest(request.deadline);
}

Expand All @@ -262,7 +262,7 @@ contract ERC2771Forwarder is EIP712, Nonces {
}

// Ignore an invalid request because requireValidRequest = false
if (signerMatch && alive) {
if (signerMatch && unexpired) {
// Nonce should be used before the call to prevent reusing by reentrancy
uint256 currentNonce = _useNonce(signer);

Expand Down
8 changes: 4 additions & 4 deletions contracts/proxy/ERC1967/ERC1967Proxy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ import {ERC1967Utils} from "./ERC1967Utils.sol";
*/
contract ERC1967Proxy is Proxy {
/**
* @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.
* @dev Initializes the upgradeable proxy with an initial implementation specified by `implementation`.
*
* If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded
* If `_data` is nonempty, it's used as data in a delegate call to `implementation`. This will typically be an encoded
* function call, and allows initializing the storage of the proxy like a Solidity constructor.
*
* Requirements:
*
* - If `data` is empty, `msg.value` must be zero.
*/
constructor(address _logic, bytes memory _data) payable {
ERC1967Utils.upgradeToAndCall(_logic, _data);
constructor(address implementation, bytes memory _data) payable {
ERC1967Utils.upgradeToAndCall(implementation, _data);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions contracts/utils/Strings.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {SignedMath} from "./math/SignedMath.sol";
* @dev String operations.
*/
library Strings {
bytes16 private constant _SYMBOLS = "0123456789abcdef";
bytes16 private constant _HEX_DIGITS = "0123456789abcdef";
uint8 private constant _ADDRESS_LENGTH = 20;

/**
Expand All @@ -34,7 +34,7 @@ library Strings {
ptr--;
/// @solidity memory-safe-assembly
assembly {
mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
mstore8(ptr, byte(mod(value, 10), _HEX_DIGITS))
}
value /= 10;
if (value == 0) break;
Expand Down Expand Up @@ -68,7 +68,7 @@ library Strings {
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _SYMBOLS[localValue & 0xf];
buffer[i] = _HEX_DIGITS[localValue & 0xf];
localValue >>= 4;
}
if (localValue != 0) {
Expand Down

0 comments on commit 94a3d2a

Please sign in to comment.