smartbugs-curated/dataset/reentrancy/0x7541b76cb60f4c60af330c208...

85 lines
1.5 KiB
Solidity
Raw Normal View History

/*
* @source: etherscan.io
* @author: -
* @vulnerable_at_lines: 29
*/
pragma solidity ^0.4.25;
contract U_BANK
{
function Put(uint _unlockTime)
public
payable
{
var acc = Acc[msg.sender];
acc.balance += msg.value;
acc.unlockTime = _unlockTime>now?_unlockTime:now;
LogFile.AddMessage(msg.sender,msg.value,"Put");
}
function Collect(uint _am)
public
payable
{
var acc = Acc[msg.sender];
if( acc.balance>=MinSum && acc.balance>=_am && now>acc.unlockTime)
{
// <yes> <report> REENTRANCY
if(msg.sender.call.value(_am)())
{
acc.balance-=_am;
LogFile.AddMessage(msg.sender,_am,"Collect");
}
}
}
function()
public
payable
{
Put(0);
}
struct Holder
{
uint unlockTime;
uint balance;
}
mapping (address => Holder) public Acc;
Log LogFile;
uint public MinSum = 2 ether;
function U_BANK(address log) public{
LogFile = Log(log);
}
}
contract Log
{
struct Message
{
address Sender;
string Data;
uint Val;
uint Time;
}
Message[] public History;
Message LastMsg;
function AddMessage(address _adr,uint _val,string _data)
public
{
LastMsg.Sender = _adr;
LastMsg.Time = now;
LastMsg.Val = _val;
LastMsg.Data = _data;
History.push(LastMsg);
}
}