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.
62 lines
1.3 KiB
62 lines
1.3 KiB
4 years ago
|
// pragma solidity ^0.4.0;
|
||
4 years ago
|
|
||
|
contract ReentrancyBenign {
|
||
|
uint8 anotherVariableToChange;
|
||
|
uint8 counter = 0;
|
||
|
|
||
|
function bad0() public {
|
||
4 years ago
|
(bool success,) = msg.sender.call("");
|
||
|
if (!success) {
|
||
4 years ago
|
revert();
|
||
|
}
|
||
|
counter += 1;
|
||
|
}
|
||
|
|
||
|
function bad1(address target) public {
|
||
4 years ago
|
(bool success,) = target.call("");
|
||
4 years ago
|
require(success);
|
||
|
counter += 1;
|
||
|
}
|
||
|
|
||
|
function bad2(address target) public {
|
||
4 years ago
|
(bool success,) = target.call("");
|
||
4 years ago
|
if (success) {
|
||
4 years ago
|
address(target).call.value(1000)("");
|
||
4 years ago
|
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();
|
||
4 years ago
|
address(target).call.value(2)("");
|
||
4 years ago
|
}
|
||
|
|
||
|
function bad5(address target) public {
|
||
|
ethSender(address(0));
|
||
|
varChanger();
|
||
|
ethSender(address(0));
|
||
|
}
|
||
|
|
||
|
function externalCaller(address target) private {
|
||
4 years ago
|
address(target).call("");
|
||
4 years ago
|
}
|
||
|
|
||
|
function ethSender(address target) private {
|
||
4 years ago
|
address(target).call.value(1)("");
|
||
4 years ago
|
}
|
||
|
|
||
|
function varChanger() private {
|
||
|
anotherVariableToChange++;
|
||
|
}
|
||
|
}
|