Skip to content

Commit

Permalink
fix(multiple-arbitrable-transaction): fix re-entrancy
Browse files Browse the repository at this point in the history
fix by changing statement order, calling external contract before require checks
  • Loading branch information
0xferit committed Jan 21, 2019
1 parent 9985ea9 commit 5f72f51
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,11 @@ contract MultipleArbitrableTransaction {
*/
function payArbitrationFeeByBuyer(uint _transactionID) public payable {
Transaction storage transaction = transactions[_transactionID];
uint arbitrationCost = arbitrator.arbitrationCost(arbitratorExtraData);

require(transaction.status < Status.DisputeCreated, "Dispute has already been created or because the transaction has been executed.");
require(msg.sender == transaction.buyer, "The caller must be the buyer.");

uint arbitrationCost = arbitrator.arbitrationCost(arbitratorExtraData);
transaction.buyerFee += msg.value;
// Require that the total paid to be at least the arbitration cost.
require(transaction.buyerFee >= arbitrationCost, "The buyer fee must cover arbitration costs.");
Expand All @@ -226,10 +227,11 @@ contract MultipleArbitrableTransaction {
*/
function payArbitrationFeeBySeller(uint _transactionID) public payable {
Transaction storage transaction = transactions[_transactionID];
uint arbitrationCost = arbitrator.arbitrationCost(arbitratorExtraData);

require(transaction.status < Status.DisputeCreated, "Dispute has already been created or because the transaction has been executed.");
require(msg.sender == transaction.seller, "The caller must be the seller.");

uint arbitrationCost = arbitrator.arbitrationCost(arbitratorExtraData);
transaction.sellerFee += msg.value;
// Require that the total pay at least the arbitration cost.
require(transaction.sellerFee >= arbitrationCost, "The seller fee must cover arbitration costs.");
Expand Down

0 comments on commit 5f72f51

Please sign in to comment.