Skip to content

Commit

Permalink
pr comment
Browse files Browse the repository at this point in the history
  • Loading branch information
skosito committed Sep 16, 2024
1 parent 40385f9 commit df3576c
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions v2/contracts/evm/GatewayEVM.sol
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,7 @@ contract GatewayEVM is
/// @param data Calldata to pass to the call.
/// @return The result of the call.
function _executeArbitraryCall(address destination, bytes calldata data) internal returns (bytes memory) {
if (data.length >= 4) {
bytes4 functionSelector;
assembly {
functionSelector := calldataload(data.offset)
}

if (functionSelector == Callable.onCall.selector) {
revert NotAllowedToCallOnCall();
}
}
revertIfAuthenticatedCall(data);
(bool success, bytes memory result) = destination.call{ value: msg.value }(data);
if (!success) revert ExecutionFailed();

Expand Down Expand Up @@ -441,4 +432,18 @@ contract GatewayEVM is
IERC20(token).safeTransfer(custody, amount);
}
}

// @dev prevent calling onCall function reserved for authenticated calls
function revertIfAuthenticatedCall(bytes calldata data) private pure {
if (data.length >= 4) {
bytes4 functionSelector;
assembly {
functionSelector := calldataload(data.offset)
}

if (functionSelector == Callable.onCall.selector) {
revert NotAllowedToCallOnCall();
}
}
}
}

0 comments on commit df3576c

Please sign in to comment.