mirror of https://github.com/crytic/slither
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
72 lines
1.9 KiB
72 lines
1.9 KiB
4 years ago
|
contract C {
|
||
|
address owner;
|
||
|
|
||
|
modifier check_addr(address _addr) {
|
||
|
if (_addr != address(0)) {
|
||
|
_;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function bad0_set_owner(address new_owner) payable public{
|
||
|
owner = new_owner; // No check before use
|
||
|
}
|
||
|
|
||
4 years ago
|
function bad1_send(address addr) payable public{
|
||
4 years ago
|
addr.send(msg.value); // No check before send
|
||
|
addr.send(msg.value);
|
||
|
}
|
||
|
|
||
4 years ago
|
function bad2_transfer(address addr) payable public{
|
||
4 years ago
|
addr.transfer(msg.value); // No check before transfer
|
||
|
}
|
||
|
|
||
4 years ago
|
function bad3_transfer(address addr) payable public{
|
||
4 years ago
|
addr.transfer(msg.value);
|
||
|
require(addr != address(0)); // check after transfer just to verify detector heuristic implementation.
|
||
|
}
|
||
|
|
||
4 years ago
|
function bad4_call(address addr) payable public{
|
||
4 years ago
|
addr.call.value(msg.value)(""); // No check before call
|
||
|
}
|
||
|
|
||
|
function good0_set_owner(address new_owner) payable public{
|
||
|
if (new_owner != address(0)) { // Check
|
||
|
owner = new_owner;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function good1_set_owner() payable public{
|
||
|
owner = 0x0123456789012345678901234567890123456789; // No tainting
|
||
|
}
|
||
|
|
||
4 years ago
|
function good2_send(address addr) payable public{
|
||
4 years ago
|
if (addr != address(0)) {
|
||
|
addr.send(msg.value); // check before send
|
||
|
}
|
||
|
}
|
||
|
|
||
4 years ago
|
function good3_transfer(address addr) payable public{
|
||
4 years ago
|
if (addr != address(0)) {
|
||
|
addr.transfer(msg.value); // check before transfer
|
||
|
}
|
||
|
}
|
||
|
|
||
4 years ago
|
function good4_transfer(address addr) payable public{
|
||
4 years ago
|
require(addr != address(0));
|
||
|
addr.transfer(msg.value); // check in above require before transfer
|
||
|
}
|
||
|
|
||
4 years ago
|
function good5_transfer(address addr) payable public check_addr(addr) {
|
||
4 years ago
|
addr.transfer(msg.value); // checked in modifier before transfer
|
||
|
}
|
||
|
|
||
|
function good6_msg_sender() payable public {
|
||
|
owner = msg.sender; // msg.sender does not need to be zero validated
|
||
|
}
|
||
|
|
||
|
function good7_transfer_msg_sender() payable public {
|
||
4 years ago
|
address addr = msg.sender;
|
||
4 years ago
|
addr.transfer(msg.value); // msg.sender does not need to be zero validated
|
||
|
}
|
||
|
}
|