mirror of https://github.com/crytic/slither
reentrancy-no-eth: do not count staticcalls as reentrant (#1119)
* reentrancy-no-eth: do not count staticcalls as reentrant * change can_reenter of low-level-calls to false for staticcallpull/1130/head
parent
c57e272d6c
commit
bab44b77d2
@ -0,0 +1,20 @@ |
|||||||
|
library MyLibrary { |
||||||
|
|
||||||
|
function aViewCall(address token) internal view { |
||||||
|
(bool success ,) = token.staticcall(abi.encodeWithSignature("decimals")); |
||||||
|
require(success, "call failed"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
contract A { |
||||||
|
uint256 private protectMe = 1; |
||||||
|
function good() external { |
||||||
|
MyLibrary.aViewCall(0x6B175474E89094C44Da98b954EedeAC495271d0F); |
||||||
|
protectMe += 1; |
||||||
|
} |
||||||
|
function good1() external { |
||||||
|
(bool success,) = address(MyLibrary).staticcall(abi.encodeWithSignature("aViewCall(address)")); |
||||||
|
require(success, "call failed"); |
||||||
|
protectMe += 1; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,3 @@ |
|||||||
|
[ |
||||||
|
[] |
||||||
|
] |
@ -0,0 +1,26 @@ |
|||||||
|
interface IERC20 { |
||||||
|
function decimals() external view returns (uint8); |
||||||
|
} |
||||||
|
|
||||||
|
library MyLibrary { |
||||||
|
|
||||||
|
function aViewCall(address token) internal view { |
||||||
|
(bool success , ) = token.staticcall( |
||||||
|
abi.encodeWithSelector(IERC20.decimals.selector) |
||||||
|
); |
||||||
|
require(success, "call failed"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
contract A { |
||||||
|
uint256 private protectMe = 1; |
||||||
|
function good() external { |
||||||
|
MyLibrary.aViewCall(0x6B175474E89094C44Da98b954EedeAC495271d0F); |
||||||
|
protectMe += 1; |
||||||
|
} |
||||||
|
function good1() external { |
||||||
|
(bool success,) = address(MyLibrary).staticcall(abi.encodeWithSignature("aViewCall(address)")); |
||||||
|
require(success, "call failed"); |
||||||
|
protectMe += 1; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,3 @@ |
|||||||
|
[ |
||||||
|
[] |
||||||
|
] |
@ -0,0 +1,25 @@ |
|||||||
|
interface IERC20 { |
||||||
|
function decimals() external view returns (uint8); |
||||||
|
} |
||||||
|
|
||||||
|
library MyLibrary { |
||||||
|
|
||||||
|
function aViewCall(address token) internal view { |
||||||
|
(bool success , ) = token.staticcall( |
||||||
|
abi.encodeWithSelector(IERC20.decimals.selector) |
||||||
|
); |
||||||
|
require(success, "call failed"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
contract A { |
||||||
|
uint256 private protectMe = 1; function good() external { |
||||||
|
MyLibrary.aViewCall(0x6B175474E89094C44Da98b954EedeAC495271d0F); |
||||||
|
protectMe += 1; |
||||||
|
} |
||||||
|
function good1() external { |
||||||
|
(bool success,) = address(MyLibrary).staticcall(abi.encodeWithSignature("aViewCall(address)")); |
||||||
|
require(success, "call failed"); |
||||||
|
protectMe += 1; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,3 @@ |
|||||||
|
[ |
||||||
|
[] |
||||||
|
] |
Loading…
Reference in new issue