Skip to content

Commit

Permalink
add missing zero address validation checks
Browse files Browse the repository at this point in the history
  • Loading branch information
gianchandania committed Jan 23, 2024
1 parent ae3d92b commit 48aa44f
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions contracts/Batcher.sol
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ contract Batcher {
for (uint8 i = 0; i < recipients.length; i++) {
require(recipients[i] != address(0), 'Invalid recipient address');
emit BatchTransfer(msg.sender, recipients[i], values[i]);

(bool success, ) = recipients[i].call{
value: values[i],
gas: transferGasLimit
Expand All @@ -91,6 +92,7 @@ contract Batcher {
uint256 value,
bytes calldata data
) external onlyOwner returns (bytes memory) {
require(to != address(0), 'Invalid recipient address');
(bool success, bytes memory returnData) = to.call{ value: value }(data);
require(success, 'Recover failed');
return returnData;
Expand Down
1 change: 1 addition & 0 deletions contracts/Forwarder.sol
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ contract Forwarder is IERC721Receiver, ERC1155Receiver, IForwarder {
uint256 value,
bytes calldata data
) external onlyParent returns (bytes memory) {
require(target != address(0), 'Invalid target address');
(bool success, bytes memory returnedData) = target.call{ value: value }(
data
);
Expand Down
4 changes: 4 additions & 0 deletions contracts/ForwarderFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ contract ForwarderFactory is CloneFactory {
);

constructor(address _implementationAddress) {
require(
_implementationAddress != address(0),
'Invalid implementation address'
);
implementationAddress = _implementationAddress;
}

Expand Down
5 changes: 5 additions & 0 deletions contracts/ForwarderFactoryV4.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ contract ForwarderFactoryV4 is CloneFactory {
* @param _implementationAddress Address of the current forwarder implementation
*/
constructor(address _implementationAddress) {
require(
_implementationAddress != address(0),
'Invalid implementation address'
);
implementationAddress = _implementationAddress;
}

Expand Down Expand Up @@ -67,6 +71,7 @@ contract ForwarderFactoryV4 is CloneFactory {
bytes32 finalSalt = keccak256(abi.encodePacked(parent, feeAddress, salt));

address payable clone = createClone(implementationAddress, finalSalt);

emit ForwarderCreated(
clone,
parent,
Expand Down
2 changes: 2 additions & 0 deletions contracts/ForwarderV4.sol
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ contract ForwarderV4 is IERC721Receiver, ERC1155Receiver, IForwarderV4 {
* the sender to the forwarder itself
*/
emit ForwarderDeposited(address(this), value, msg.data);

(bool success, ) = parentAddress.call{ value: value }('');
require(success, 'Flush failed');
}
Expand Down Expand Up @@ -164,6 +165,7 @@ contract ForwarderV4 is IERC721Receiver, ERC1155Receiver, IForwarderV4 {
bytes calldata data
) external returns (bytes memory) {
require(msg.sender == parentAddress, 'Only Parent');
require(target != address(0), 'Invalid target address');
(bool success, bytes memory returnedData) = target.call{ value: value }(
data
);
Expand Down
4 changes: 4 additions & 0 deletions contracts/WalletFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ contract WalletFactory is CloneFactory {
event WalletCreated(address newWalletAddress, address[] allowedSigners);

constructor(address _implementationAddress) {
require(
_implementationAddress != address(0),
'Invalid implementation address'
);
implementationAddress = _implementationAddress;
}

Expand Down
2 changes: 2 additions & 0 deletions contracts/WalletSimple.sol
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ contract WalletSimple is IERC721Receiver, ERC1155Receiver {
uint256 sequenceId,
bytes calldata signature
) external onlySigner {
require(toAddress != address(0), 'Invalid destination address');

// Verify the other signer
bytes32 operationHash = keccak256(
abi.encodePacked(
Expand Down
1 change: 1 addition & 0 deletions contracts/recoveryContracts/RecoveryWalletFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ contract RecoveryWalletFactory is CloneFactory {
address public implementationAddress;

constructor(address _implementationAddress) {
require(_implementationAddress != address(0), 'Invalid implementation address');
implementationAddress = _implementationAddress;
}

Expand Down
2 changes: 2 additions & 0 deletions contracts/recoveryContracts/RecoveryWalletSimple.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ contract RecoveryWalletSimple is IERC721Receiver, ERC1155Receiver {
bool public initialized = false; // True if the contract has been initialized

function init(address _signer) external onlyUninitialized {
require(_signer != address(0), 'Invalid signer address');
signer = _signer;
initialized = true;
}
Expand Down Expand Up @@ -62,6 +63,7 @@ contract RecoveryWalletSimple is IERC721Receiver, ERC1155Receiver {
uint256 value,
bytes calldata data
) external onlySigner {
require(toAddress != address(0), 'Invalid destination address');
// Success, send the transaction
(bool success, ) = toAddress.call{ value: value }(data);
require(success, 'Call execution failed');
Expand Down

0 comments on commit 48aa44f

Please sign in to comment.