Skip to content

Commit

Permalink
fix: L-02 check for receiver or target teller being zero address
Browse files Browse the repository at this point in the history
  • Loading branch information
junkim012 committed Dec 20, 2024
1 parent fe84445 commit a753911
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/base/Roles/CrossChain/MultiChainTellerBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ struct Chain {
error MultiChainTellerBase_MessagesNotAllowedFrom(uint32 chainSelector);
error MultiChainTellerBase_MessagesNotAllowedFromSender(uint256 chainSelector, address sender);
error MultiChainTellerBase_MessagesNotAllowedTo(uint256 chainSelector);
error MultiChainTellerBase_TargetTellerIsZeroAddress();
error MultiChainTellerBase_DestinationChainReceiverIsZeroAddress();
error MultiChainTellerBase_ZeroMessageGasLimit();
error MultiChainTellerBase_GasLimitExceeded();
error MultiChainTellerBase_GasTooLow();
Expand Down Expand Up @@ -172,15 +174,25 @@ abstract contract MultiChainTellerBase is CrossChainTellerBase {
* @param data bridge data
*/
function _beforeBridge(BridgeData calldata data) internal override {
if (!selectorToChains[data.chainSelector].allowMessagesTo) {
Chain chain = selectorToChains[data.chainSelector];

if (!chain.allowMessagesTo) {
revert MultiChainTellerBase_MessagesNotAllowedTo(data.chainSelector);
}

if (data.messageGas > selectorToChains[data.chainSelector].messageGasLimit) {
if (chain.targetTeller == address(0)) {
revert MultiChainTellerBase_TargetTellerIsZeroAddress();
}

if (data.destinationChainReceiver == address(0)) {
revert MultiChainTellerBase_DestinationChainReceiverIsZeroAddress();
}

if (data.messageGas > chain.messageGasLimit) {
revert MultiChainTellerBase_GasLimitExceeded();
}

if (data.messageGas < selectorToChains[data.chainSelector].minimumMessageGas) {
if (data.messageGas < chain.minimumMessageGas) {
revert MultiChainTellerBase_GasTooLow();
}
}
Expand Down

0 comments on commit a753911

Please sign in to comment.