Skip to content

Commit

Permalink
Merge pull request #199 from bcnmy/fix/check-zero-address
Browse files Browse the repository at this point in the history
fix: k1 validator 0 address check
  • Loading branch information
livingrockrises authored Oct 7, 2024
2 parents fa19840 + 452bf0c commit 79376bc
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions contracts/modules/validators/K1Validator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ contract K1Validator is IValidator, ERC7739Validator {
/// @notice Error to indicate that the new owner cannot be a contract address
error NewOwnerIsContract();

/// @notice Error to indicate that the owner cannot be the zero address
error OwnerCannotBeZeroAddress();

/// @notice Error to indicate that the data length is invalid
error InvalidDataLength();

Expand All @@ -72,6 +75,7 @@ contract K1Validator is IValidator, ERC7739Validator {
require(data.length != 0, NoOwnerProvided());
require(!_isInitialized(msg.sender), ModuleAlreadyInitialized());
address newOwner = address(bytes20(data[:20]));
require(newOwner != address(0), OwnerCannotBeZeroAddress());
require(!_isContract(newOwner), NewOwnerIsContract());
smartAccountOwners[msg.sender] = newOwner;
if (data.length > 20) {
Expand Down

0 comments on commit 79376bc

Please sign in to comment.