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.
42 lines
888 B
42 lines
888 B
4 years ago
|
// pragma solidity 0.4.26;
|
||
4 years ago
|
|
||
|
contract ReentrancyWrite {
|
||
|
bool notCalled = true;
|
||
|
|
||
3 years ago
|
// Should not detect reentrancy in constructor
|
||
|
constructor(address addr) public {
|
||
|
require(notCalled);
|
||
|
(bool success,) = addr.call("");
|
||
|
if (!success) {
|
||
|
revert();
|
||
|
}
|
||
|
notCalled = false;
|
||
|
}
|
||
|
|
||
4 years ago
|
function bad0() public {
|
||
|
require(notCalled);
|
||
4 years ago
|
(bool success,) = msg.sender.call("");
|
||
|
if (!success) {
|
||
4 years ago
|
revert();
|
||
|
}
|
||
|
notCalled = false;
|
||
|
}
|
||
|
|
||
|
function bad1(address target) public {
|
||
|
require(notCalled);
|
||
4 years ago
|
(bool success,) = msg.sender.call("");
|
||
4 years ago
|
require(success);
|
||
|
bad0();
|
||
|
}
|
||
|
|
||
|
function good() public {
|
||
|
require(notCalled);
|
||
|
notCalled = true;
|
||
4 years ago
|
(bool success,) = msg.sender.call("");
|
||
|
if (!success) {
|
||
4 years ago
|
revert();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|