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.
71 lines
1.6 KiB
71 lines
1.6 KiB
// pragma solidity ^0.4.0;
|
|
|
|
contract ReentrancyBenign {
|
|
uint8 anotherVariableToChange;
|
|
uint8 counter = 0;
|
|
|
|
// Should not detect reentrancy in constructor
|
|
constructor(address addr) public {
|
|
(bool success,) = addr.call("");
|
|
if (!success) {
|
|
revert();
|
|
}
|
|
counter += 1;
|
|
}
|
|
|
|
function bad0() public {
|
|
(bool success,) = msg.sender.call("");
|
|
if (!success) {
|
|
revert();
|
|
}
|
|
counter += 1;
|
|
}
|
|
|
|
function bad1(address target) public {
|
|
(bool success,) = target.call("");
|
|
require(success);
|
|
counter += 1;
|
|
}
|
|
|
|
function bad2(address target) public {
|
|
(bool success,) = target.call("");
|
|
if (success) {
|
|
address(target).call.value(1000)("");
|
|
counter += 1;
|
|
}
|
|
else {
|
|
revert();
|
|
}
|
|
}
|
|
|
|
function bad3(address target) public {
|
|
externalCaller(target);
|
|
varChanger();
|
|
ethSender(target);
|
|
}
|
|
|
|
function bad4(address target) public {
|
|
externalCaller(target);
|
|
ethSender(address(0));
|
|
varChanger();
|
|
address(target).call.value(2)("");
|
|
}
|
|
|
|
function bad5(address target) public {
|
|
ethSender(address(0));
|
|
varChanger();
|
|
ethSender(address(0));
|
|
}
|
|
|
|
function externalCaller(address target) private {
|
|
address(target).call("");
|
|
}
|
|
|
|
function ethSender(address target) private {
|
|
address(target).call.value(1)("");
|
|
}
|
|
|
|
function varChanger() private {
|
|
anotherVariableToChange++;
|
|
}
|
|
} |