Skip to content

Commit

Permalink
Fix Immunefi Report #31869 (#174)
Browse files Browse the repository at this point in the history
  • Loading branch information
hujw77 authored Jun 3, 2024
1 parent ed758a0 commit cadfae4
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 17 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@msgport/ormp",
"version": "2.0.0",
"version": "2.1.0",
"description": "Oracle and Relayer based Message Protocol",
"repository": "https://github.com/msgport/ORMP",
"author": "Msgport dev",
Expand Down
9 changes: 3 additions & 6 deletions src/ORMP.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ contract ORMP is ReentrancyGuard, Channel {
constructor(address dao) Channel(dao) {}

function version() public pure returns (string memory) {
return "2.0.0";
return "2.1.0";
}

/// @dev Send a cross-chain message over the endpoint.
Expand Down Expand Up @@ -92,6 +92,7 @@ contract ORMP is ReentrancyGuard, Channel {
emit MessageAssigned(msgHash, uc.oracle, uc.relayer, oracleFee, relayerFee, params);

// refund
require(msg.value >= relayerFee + oracleFee, "!fee");
if (msg.value > relayerFee + oracleFee) {
uint256 refundFee = msg.value - (relayerFee + oracleFee);
_sendValue(refund, refundFee);
Expand Down Expand Up @@ -141,7 +142,6 @@ contract ORMP is ReentrancyGuard, Channel {
/// @return dispatchResult Result of the message dispatch.
function recv(Message calldata message, bytes calldata proof)
external
payable
recvNonReentrant
returns (bool dispatchResult)
{
Expand All @@ -158,10 +158,7 @@ contract ORMP is ReentrancyGuard, Channel {
require(gasAvailable - gasAvailable / 64 > message.gasLimit, "!gas");
// Deliver the message to user application contract address.
(dispatchResult,) = message.to.excessivelySafeCall(
message.gasLimit,
msg.value,
0,
abi.encodePacked(message.encoded, msgHash, message.fromChainId, message.from)
message.gasLimit, 0, 0, abi.encodePacked(message.encoded, msgHash, message.fromChainId, message.from)
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/eco/Oracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ contract Oracle is Verifier {
receive() external payable {}

function version() public pure returns (string memory) {
return "2.0.0";
return "2.1.0";
}

/// @dev Only could be called by owner.
Expand Down
2 changes: 1 addition & 1 deletion src/eco/Relayer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ contract Relayer {
}

function version() public pure returns (string memory) {
return "2.0.0";
return "2.1.0";
}

receive() external payable {}
Expand Down
9 changes: 3 additions & 6 deletions tron/ORMP.f.sol
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ contract ORMP is ReentrancyGuard, Channel {
constructor(address dao) Channel(dao) {}

function version() public pure returns (string memory) {
return "2.0.0";
return "2.1.0";
}

/// @dev Send a cross-chain message over the endpoint.
Expand Down Expand Up @@ -471,6 +471,7 @@ contract ORMP is ReentrancyGuard, Channel {
emit MessageAssigned(msgHash, uc.oracle, uc.relayer, oracleFee, relayerFee, params);

// refund
require(msg.value >= relayerFee + oracleFee, "!fee");
if (msg.value > relayerFee + oracleFee) {
uint256 refundFee = msg.value - (relayerFee + oracleFee);
_sendValue(refund, refundFee);
Expand Down Expand Up @@ -520,7 +521,6 @@ contract ORMP is ReentrancyGuard, Channel {
/// @return dispatchResult Result of the message dispatch.
function recv(Message calldata message, bytes calldata proof)
external
payable
recvNonReentrant
returns (bool dispatchResult)
{
Expand All @@ -537,10 +537,7 @@ contract ORMP is ReentrancyGuard, Channel {
require(gasAvailable - gasAvailable / 64 > message.gasLimit, "!gas");
// Deliver the message to user application contract address.
(dispatchResult,) = message.to.excessivelySafeCall(
message.gasLimit,
msg.value,
0,
abi.encodePacked(message.encoded, msgHash, message.fromChainId, message.from)
message.gasLimit, 0, 0, abi.encodePacked(message.encoded, msgHash, message.fromChainId, message.from)
);
}

Expand Down
2 changes: 1 addition & 1 deletion tron/Oracle.f.sol
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ contract Oracle is Verifier {
receive() external payable {}

function version() public pure returns (string memory) {
return "2.0.0";
return "2.1.0";
}

/// @dev Only could be called by owner.
Expand Down
2 changes: 1 addition & 1 deletion tron/Relayer.f.sol
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ contract Relayer {
}

function version() public pure returns (string memory) {
return "2.0.0";
return "2.1.0";
}

receive() external payable {}
Expand Down

0 comments on commit cadfae4

Please sign in to comment.