Add SB Curated (copied from the smartbugs repository).
This commit is contained in:
32
dataset/reentrancy/reentrance.sol
Normal file
32
dataset/reentrancy/reentrance.sol
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* @source: https://ethernaut.zeppelin.solutions/level/0xf70706db003e94cfe4b5e27ffd891d5c81b39488
|
||||
* @author: Alejandro Santander
|
||||
* @vulnerable_at_lines: 24
|
||||
*/
|
||||
|
||||
pragma solidity ^0.4.18;
|
||||
|
||||
contract Reentrance {
|
||||
|
||||
mapping(address => uint) public balances;
|
||||
|
||||
function donate(address _to) public payable {
|
||||
balances[_to] += msg.value;
|
||||
}
|
||||
|
||||
function balanceOf(address _who) public view returns (uint balance) {
|
||||
return balances[_who];
|
||||
}
|
||||
|
||||
function withdraw(uint _amount) public {
|
||||
if(balances[msg.sender] >= _amount) {
|
||||
// <yes> <report> REENTRANCY
|
||||
if(msg.sender.call.value(_amount)()) {
|
||||
_amount;
|
||||
}
|
||||
balances[msg.sender] -= _amount;
|
||||
}
|
||||
}
|
||||
|
||||
function() public payable {}
|
||||
}
|
||||
Reference in New Issue
Block a user