Add SB Curated (copied from the smartbugs repository).
This commit is contained in:
31
dataset/reentrancy/etherstore.sol
Normal file
31
dataset/reentrancy/etherstore.sol
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* @source: https://github.com/sigp/solidity-security-blog
|
||||
* @author: Suhabe Bugrara
|
||||
* @vulnerable_at_lines: 27
|
||||
*/
|
||||
|
||||
//added pragma version
|
||||
pragma solidity ^0.4.0;
|
||||
|
||||
contract EtherStore {
|
||||
|
||||
uint256 public withdrawalLimit = 1 ether;
|
||||
mapping(address => uint256) public lastWithdrawTime;
|
||||
mapping(address => uint256) public balances;
|
||||
|
||||
function depositFunds() public payable {
|
||||
balances[msg.sender] += msg.value;
|
||||
}
|
||||
|
||||
function withdrawFunds (uint256 _weiToWithdraw) public {
|
||||
require(balances[msg.sender] >= _weiToWithdraw);
|
||||
// limit the withdrawal
|
||||
require(_weiToWithdraw <= withdrawalLimit);
|
||||
// limit the time allowed to withdraw
|
||||
require(now >= lastWithdrawTime[msg.sender] + 1 weeks);
|
||||
// <yes> <report> REENTRANCY
|
||||
require(msg.sender.call.value(_weiToWithdraw)());
|
||||
balances[msg.sender] -= _weiToWithdraw;
|
||||
lastWithdrawTime[msg.sender] = now;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user