Add SB Curated (copied from the smartbugs repository).
This commit is contained in:
29
dataset/reentrancy/reentrancy_simple.sol
Normal file
29
dataset/reentrancy/reentrancy_simple.sol
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* @source: https://github.com/trailofbits/not-so-smart-contracts/blob/master/reentrancy/Reentrancy.sol
|
||||
* @author: -
|
||||
* @vulnerable_at_lines: 24
|
||||
*/
|
||||
|
||||
pragma solidity ^0.4.15;
|
||||
|
||||
contract Reentrance {
|
||||
mapping (address => uint) userBalance;
|
||||
|
||||
function getBalance(address u) constant returns(uint){
|
||||
return userBalance[u];
|
||||
}
|
||||
|
||||
function addToBalance() payable{
|
||||
userBalance[msg.sender] += msg.value;
|
||||
}
|
||||
|
||||
function withdrawBalance(){
|
||||
// send userBalance[msg.sender] ethers to msg.sender
|
||||
// if mgs.sender is a contract, it will call its fallback function
|
||||
// <yes> <report> REENTRANCY
|
||||
if( ! (msg.sender.call.value(userBalance[msg.sender])() ) ){
|
||||
throw;
|
||||
}
|
||||
userBalance[msg.sender] = 0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user