Add SB Curated (copied from the smartbugs repository).
This commit is contained in:
27
dataset/reentrancy/simple_dao.sol
Normal file
27
dataset/reentrancy/simple_dao.sol
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* @source: http://blockchain.unica.it/projects/ethereum-survey/attacks.html#simpledao
|
||||
* @author: -
|
||||
* @vulnerable_at_lines: 19
|
||||
*/
|
||||
|
||||
pragma solidity ^0.4.2;
|
||||
|
||||
contract SimpleDAO {
|
||||
mapping (address => uint) public credit;
|
||||
|
||||
function donate(address to) payable {
|
||||
credit[to] += msg.value;
|
||||
}
|
||||
|
||||
function withdraw(uint amount) {
|
||||
if (credit[msg.sender]>= amount) {
|
||||
// <yes> <report> REENTRANCY
|
||||
bool res = msg.sender.call.value(amount)();
|
||||
credit[msg.sender]-=amount;
|
||||
}
|
||||
}
|
||||
|
||||
function queryCredit(address to) returns (uint){
|
||||
return credit[to];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user