-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
llvm-context: disable call re-entrancy for send and transfer (#196)
- Loading branch information
Showing
8 changed files
with
354 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8; | ||
|
||
/* runner.json | ||
{ | ||
"differential": true, | ||
"actions": [ | ||
{ | ||
"Upload": { | ||
"code": { | ||
"Solidity": { | ||
"contract": "BalanceReceiver" | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
"Instantiate": { | ||
"code": { | ||
"Solidity": { | ||
"contract": "Balance" | ||
} | ||
}, | ||
"value": 24 | ||
} | ||
}, | ||
{ | ||
"Call": { | ||
"dest": { | ||
"Instantiated": 0 | ||
}, | ||
"data": "1c8d16b30000000000000000000000000303030303030303030303030303030303030303000000000000000000000000000000000000000000000000000000000000000a" | ||
} | ||
}, | ||
{ | ||
"Call": { | ||
"dest": { | ||
"Instantiated": 0 | ||
}, | ||
"data": "6ada15d90000000000000000000000000303030303030303030303030303030303030303000000000000000000000000000000000000000000000000000000000000000a" | ||
} | ||
} | ||
] | ||
} | ||
*/ | ||
|
||
contract BalanceReceiver { | ||
constructor() payable {} | ||
|
||
fallback() external payable {} | ||
} | ||
|
||
contract Balance { | ||
constructor() payable { | ||
// 0 to EOA | ||
transfer_to(payable(address(0xdeadbeef)), 0); | ||
send_to(payable(address(0xdeadbeef)), 0); | ||
|
||
// 1 to EOA | ||
transfer_to(payable(address(0xcafebabe)), 1); | ||
send_to(payable(address(0xcafebabe)), 1); | ||
|
||
BalanceReceiver balanceReceiver = new BalanceReceiver(); | ||
|
||
// 0 to contract | ||
transfer_to(payable(address(balanceReceiver)), 0); | ||
send_to(payable(address(balanceReceiver)), 0); | ||
|
||
// 1 to contract | ||
transfer_to(payable(address(balanceReceiver)), 1); | ||
send_to(payable(address(balanceReceiver)), 1); | ||
} | ||
|
||
function transfer_to(address payable _dest, uint _amount) public payable { | ||
_dest.transfer(_amount); | ||
} | ||
|
||
function send_to(address payable _dest, uint _amount) public payable { | ||
require(_dest.send(_amount)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8; | ||
|
||
/* runner.json | ||
{ | ||
"differential": false, | ||
"actions": [ | ||
{ | ||
"Instantiate": { | ||
"code": { | ||
"Solidity": { | ||
"contract": "Send" | ||
} | ||
}, | ||
"value": 211 | ||
} | ||
}, | ||
{ | ||
"Call": { | ||
"dest": { | ||
"Instantiated": 0 | ||
}, | ||
"data": "1c8d16b30000000000000000000000000303030303030303030303030303030303030303000000000000000000000000000000000000000000000000000000000000000a" | ||
} | ||
}, | ||
{ | ||
"VerifyCall": { | ||
"success": true | ||
} | ||
}, | ||
{ | ||
"Call": { | ||
"dest": { | ||
"Instantiated": 0 | ||
}, | ||
"data": "fb9e8d050000000000000000000000000000000000000000000000000000000000000001" | ||
} | ||
}, | ||
{ | ||
"VerifyCall": { | ||
"success": false | ||
} | ||
}, | ||
{ | ||
"Call": { | ||
"dest": { | ||
"Instantiated": 0 | ||
}, | ||
"data": "fb9e8d050000000000000000000000000000000000000000000000000000000000000000" | ||
} | ||
}, | ||
{ | ||
"VerifyCall": { | ||
"success": false | ||
} | ||
} | ||
] | ||
} | ||
*/ | ||
|
||
contract Send { | ||
constructor() payable {} | ||
|
||
function transfer_self(uint _amount) public payable { | ||
transfer_to(payable(address(this)), _amount); | ||
} | ||
|
||
function transfer_to(address payable _dest, uint _amount) public payable { | ||
if (_dest.send(_amount)) {} | ||
} | ||
|
||
fallback() external {} | ||
|
||
receive() external payable {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.