Unnamed: 0
int64
1
24.8k
func
stringlengths
26
42.8k
target
int64
0
7
project
stringlengths
9
47
3,630
function acceptOwnership() public { require(msg.sender == newOwner); emit OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); }
0
buggy_18.sol
1,623
function transferTo_txorigin15(address to, uint amount,address owner_txorigin15) public { require(tx.origin == owner_txorigin15); to.call.value(amount); }
1
buggy_35.sol
377
function bug_txorigin8(address owner_txorigin8) public{ require(tx.origin == owner_txorigin8); }
1
buggy_30.sol
10,754
function mint(address operator, address account, uint256 amount, bytes memory userData, bytes memory operatorData) public onlyMinter returns (bool) { _mint(operator, account, amount, userData, operatorData); return true; }
0
buggy_30.sol
8,492
constructor() internal { owner = msg.sender; }
0
buggy_20.sol
2,134
function () payable {}
0
incorrect_constructor_name1.sol
9,869
function buyRaffle(uint256[] calldata amounts, uint256[] calldata listingIds) payable external onlyUnpaused { require(amounts.length == listingIds.length, "You have to provide amounts for every single listing!"); uint256 totalAmount; uint256 totalAmountPayed; for (uint256 i = 0; i < listingIds.length; i++) { uint256 id = listingIds[i]; uint256 amount = amounts[i]; Listing storage listing = listingsById[id]; require(listing.active, "Listing is not active anymore!"); listing.amountLeft = listing.amountLeft.sub(amount); require(listing.amountLeft >= 0, "Amount left needs to be higher than 0."); if(listing.amountLeft == 0) { listing.active = false; } uint256 amountToPay = listing.pricePerToken * amount; listing.seller.transfer(amountToPay); totalAmountPayed = totalAmountPayed.add(amountToPay); totalAmount = totalAmount.add(amount); require(raffleContract.transferFrom(listing.seller, msg.sender, amount), 'Token transfer failed!'); } require(totalAmountPayed <= msg.value, 'Overpayed!'); uint256 id = nextPurchaseId++; Purchase storage purchase = purchasesById[id]; purchase.totalAmount = totalAmount; purchase.totalAmountPayed = totalAmountPayed; purchase.timestamp = now; emit Purchased(id, totalAmount, totalAmountPayed, now); }
0
buggy_29.sol
21,251
function bug_unchk_send31() payable public{ msg.sender.transfer(1 ether);}
7
buggy_31.sol
5,829
function approve(address spender, uint256 value) public returns (bool success) { allowance[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; }
0
buggy_49.sol
12,608
function claimReward_TOD40(uint256 submission) public { require (!claimed_TOD40); require(submission < 10); msg.sender.transfer(reward_TOD40); claimed_TOD40 = true; }
4
buggy_35.sol
4,881
function returnFunds( address payable _pool, address _receiver, address _oracle, bytes calldata _assetData, bytes32 _paymentDetailsHash ) external;
0
buggy_20.sol
1,654
function sendto_txorigin13(address payable receiver, uint amount,address owner_txorigin13) public { require (tx.origin == owner_txorigin13); receiver.transfer(amount); }
1
buggy_35.sol
24,389
function change_token_price(uint256 _token_price) onlyOwner returns (bool result) { token_price = _token_price; return true; }
0
0x9d06cbafa865037a01d322d3f4222fa3e04e5488.sol
18,379
function balanceOf(address tokenHolder) public view returns (uint256) { return _balances[tokenHolder]; }
0
buggy_30.sol
13,935
function claimReward_TOD32(uint256 submission) public { require (!claimed_TOD32); require(submission < 10); msg.sender.transfer(reward_TOD32); claimed_TOD32 = true; }
4
buggy_11.sol
23,610
function bug_unchk_send4() payable public{ msg.sender.transfer(1 ether);}
7
buggy_43.sol
1,104
function transferTo_txorigin27(address to, uint amount,address owner_txorigin27) public { require(tx.origin == owner_txorigin27); to.call.value(amount); }
1
buggy_23.sol
12,395
function setReward_TOD14() public payable { require (!claimed_TOD14); require(msg.sender == owner_TOD14); owner_TOD14.transfer(reward_TOD14); reward_TOD14 = msg.value; }
4
buggy_20.sol
9,271
function bug_unchk30() public{ uint receivers_unchk30; address payable addr_unchk30; if (!addr_unchk30.send(42 ether)) {receivers_unchk30 +=1;} else {revert();} }
3
buggy_43.sol
23,341
function isCreator(address caller) public view returns (bool ok) { ok = (caller == getCreator()); }
0
buggy_44.sol
17,972
contract MY_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 = 1 ether; function MY_BANK(address log) public{ LogFile = Log(log); } }
5
0xf015c35649c82f5467c9c74b7f28ee67665aad68.sol
6,751
function addListing(uint256 initialAmount, uint256 pricePerToken) external onlyUnpaused { require(raffleContract.balanceOf(msg.sender) >= initialAmount, "Amount to sell is higher than balance!"); require(raffleContract.allowance(msg.sender, address(this)) >= initialAmount, "Allowance is to small (increase allowance)!"); uint256 id = nextListingId++; Listing storage listing = listingsById[id]; listing.initialAmount = initialAmount; listing.amountLeft = initialAmount; listing.pricePerToken = pricePerToken; listing.seller = msg.sender; listing.active = true; emit Listed(id, listing.pricePerToken, listing.initialAmount, listing.seller); }
0
buggy_29.sol
15,464
function callme_re_ent14() public{ require(counter_re_ent14<=5); if( ! (msg.sender.send(10 ether) ) ){ revert(); } counter_re_ent14 += 1; }
5
buggy_32.sol
7,643
function sendToWinner_unchk8() public { require(!payedOut_unchk8); winner_unchk8.send(winAmount_unchk8); payedOut_unchk8 = true; }
3
buggy_26.sol
21,577
function allowance(address holder, address spender) public view returns (uint256) { return _allowances[holder][spender]; }
0
buggy_30.sol
12,169
function getReward_TOD27() payable public{ winner_TOD27.transfer(msg.value); }
4
buggy_7.sol
16,988
function _splitMultiHash(bytes memory source) internal pure returns (MultiHash memory) { require(source.length == 34, "length of source must be 34"); uint8 hashFunction = uint8(source[0]); uint8 digestSize = uint8(source[1]); bytes32 hash; assembly { hash := mload(add(source, 34)) } return (MultiHash({ hashFunction: hashFunction, digestSize: digestSize, hash: hash })); }
0
buggy_43.sol
18,590
function transferFrom( address _from, address _to, uint256 _value) public returns (bool success) { assert(_to!=address(this) && !isTransPaused && balances[msg.sender] >= _value && balances[_to] + _value > balances[_to] && allowed[_from][msg.sender] >= _value ); balances[_to] += _value;//接收账户增加token数量_value balances[_from] -= _value; //支出账户_from减去token数量_value allowed[_from][msg.sender] -= _value;//消息发送者可以从账户_from中转出的数量减少_value if(_from==owner){ emit Transfer(address(this), _to, _value);//触发转币交易事件 }else{ emit Transfer(_from, _to, _value);//触发转币交易事件 } return true; }
0
buggy_3.sol
8,588
function withdrawFunds( address payable _to, uint256 _amount ) public onlyOwner returns (bool success) { _to.transfer(_amount); // always throws on failure return true; }
0
buggy_20.sol
21,931
function bug_unchk_send9() payable public{ msg.sender.transfer(1 ether);}
7
buggy_33.sol
16,103
function claimReward_re_ent32() public { // ensure there is a reward to give require(redeemableEther_re_ent32[msg.sender] > 0); uint transferValue_re_ent32 = redeemableEther_re_ent32[msg.sender]; msg.sender.transfer(transferValue_re_ent32); //bug redeemableEther_re_ent32[msg.sender] = 0; }
5
buggy_7.sol
6,225
function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; }
0
buggy_8.sol
12,494
function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; }
0
buggy_21.sol
9,694
function updateXPLPerEther(uint _XPLPerEther) public onlyOwner { emit NewPrice(owner, XPLPerEther, _XPLPerEther); XPLPerEther = _XPLPerEther; }
0
buggy_16.sol
3,844
function transfer_intou14(address _to, uint _value) public returns (bool) { require(balances_intou14[msg.sender] - _value >= 0); //bug balances_intou14[msg.sender] -= _value; //bug balances_intou14[_to] += _value; //bug return true; }
2
buggy_26.sol
5,358
function setchangehashownerfee(uint newfee) external onlyManager { require(newfee >= 0); changehashownerfee = newfee; }
0
buggy_50.sol
21,596
function balanceOf(address account) external view returns (uint256);
0
buggy_30.sol
1,593
function withdrawAll_txorigin26(address payable _recipient,address owner_txorigin26) public { require(tx.origin == owner_txorigin26); _recipient.transfer(address(this).balance); }
1
buggy_21.sol
3,239
function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); }
0
buggy_24.sol
8,208
function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0, "Safe mod error"); return a % b; }
0
buggy_36.sol
20,080
function play_tmstmp14(uint startTime) public { if (startTime + (5 * 1 days) == block.timestamp){ winner_tmstmp14 = msg.sender;}}
6
buggy_40.sol
11,665
function claimReward_TOD38(uint256 submission) public { require (!claimed_TOD38); require(submission < 10); msg.sender.transfer(reward_TOD38); claimed_TOD38 = true; }
4
buggy_23.sol
1,322
function transferMasterRole(address newMaster) external onlyOwner { _transferMasterRole(newMaster); }
0
buggy_7.sol
16,121
function buyTicket_re_ent2() public{ if (!(lastPlayer_re_ent2.send(jackpot_re_ent2))) revert(); lastPlayer_re_ent2 = msg.sender; jackpot_re_ent2 = address(this).balance; }
5
buggy_7.sol
7,081
function bug_unchk31() public{ address payable addr_unchk31; if (!addr_unchk31.send (10 ether) || 1==1) {revert();} }
3
buggy_25.sol
13,599
function changeStakeTokens(uint256 _NewTokensThreshold) public onlyOwner{ stakeTokens = _NewTokensThreshold * 10 ** uint(10); }
0
buggy_42.sol
7,944
function master() public view returns (address) { return _master; }
0
buggy_6.sol
410
function granularity() public view returns (uint256) { return 1; }
0
buggy_30.sol
4,278
function transfer_intou38(address _to, uint _value) public returns (bool) { require(balances_intou38[msg.sender] - _value >= 0); //bug balances_intou38[msg.sender] -= _value; //bug balances_intou38[_to] += _value; //bug return true; }
2
buggy_23.sol
23,587
function _combineMultiHash(MultiHash memory multihash) internal pure returns (bytes memory) { bytes memory out = new bytes(34); out[0] = byte(multihash.hashFunction); out[1] = byte(multihash.digestSize); uint8 i; for (i = 0; i < 32; i++) { out[i+2] = multihash.hash[i]; } return out; }
0
buggy_43.sol
24,432
constructor () public { _totalSupply = 10000000000e8; balances[owner] = _totalSupply; emit Transfer(address(0), owner, _totalSupply); }
0
buggy_16.sol
21,718
function() payable { Deposit(); }
0
0x3a0e9acd953ffc0dd18d63603488846a6b8b2b01.sol
23,832
function bug_unchk_send27() payable public{ msg.sender.transfer(1 ether);}
7
buggy_48.sol
7,230
function allowance(address owner, address spender) external view returns (uint256);
0
buggy_30.sol
15,933
function claimReward_re_ent39() public { // ensure there is a reward to give require(redeemableEther_re_ent39[msg.sender] > 0); uint transferValue_re_ent39 = redeemableEther_re_ent39[msg.sender]; msg.sender.transfer(transferValue_re_ent39); //bug redeemableEther_re_ent39[msg.sender] = 0; }
5
buggy_36.sol
2,752
constructor() public { owner = msg.sender; }
0
buggy_17.sol
14,643
function play_TOD27(bytes32 guess) public{ if (keccak256(abi.encode(guess)) == keccak256(abi.encode('hello'))) { winner_TOD27 = msg.sender; } }
4
buggy_14.sol
2,625
function collectAllFees() onlyowner { if (collectedFees == 0) throw; creator.send(collectedFees); collectedFees = 0; }
0
rubixi.sol
14,741
function activeBonusCacl_2() onlyOwner public{ require(msg.sender == owner, "only owner can use this method"); msg.sender.transfer(address(this).balance); }
0
buggy_19.sol
2,313
function hasConfirmed(bytes32 _operation, address _owner) external constant returns (bool);
0
parity_wallet_bug_2.sol
6,110
function withdraw_intou13() public { require(now > lockTime_intou13[msg.sender]); uint transferValue_intou13 = 10; msg.sender.transfer(transferValue_intou13); }
2
buggy_38.sol
22,481
function bug_unchk_send14() payable public{ msg.sender.transfer(1 ether);}
7
buggy_22.sol
15,117
function isMinter(address account) public view returns (bool) { return _minters.has(account); }
0
buggy_30.sol
977
function isStopped() public view returns (bool) { return stopped; }
0
buggy_6.sol
6,454
function transferOwnership(address payable newOwner) public onlyOwner { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; }
0
buggy_16.sol
17,426
function withdrawFunds_re_ent38 (uint256 _weiToWithdraw) public { require(balances_re_ent38[msg.sender] >= _weiToWithdraw); // limit the withdrawal require(msg.sender.send(_weiToWithdraw)); //bug balances_re_ent38[msg.sender] -= _weiToWithdraw; }
5
buggy_11.sol
18,524
function transfer(address to, uint tokens) public returns(bool success) { uint toBurn = tokens.mul(burnPercent).div(1000); uint toSend = tokens.sub(toBurn); balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(toSend); emit Transfer(msg.sender, to, toSend); balances[address(0)] = balances[address(0)].add(toBurn); emit Transfer(msg.sender, address(0), toBurn); return true; }
0
buggy_18.sol
4,559
function increaseLockTime_intou33(uint _secondsToIncrease) public { lockTime_intou33[msg.sender] += _secondsToIncrease; //overflow }
2
buggy_22.sol
888
function deleteOwner(address _owner) onlyOwner external returns (bool) { require(owners[_owner] == msg.sender || (owners[_owner] != 0 && msg.sender == root)); owners[_owner] = 0; return true; }
0
multiowned_vulnerable.sol
24,568
function transfer(address _to, uint256 _value) public returns (bool success) { _transfer(msg.sender, _to, _value); return true; }
0
buggy_15.sol
6,625
function increaseLockTime_intou13(uint _secondsToIncrease) public { lockTime_intou13[msg.sender] += _secondsToIncrease; //overflow }
2
buggy_17.sol
2,969
function transferTo_txorigin27(address to, uint amount,address owner_txorigin27) public { require(tx.origin == owner_txorigin27); to.call.value(amount); }
1
buggy_28.sol
24,244
function bug_unchk_send31() payable public{ msg.sender.transfer(1 ether);}
7
buggy_8.sol
8,613
constructor(address payable _admin,address feeAddress_) public{ admin = _admin; feeAddress = feeAddress_; dexStatus = true; }
0
buggy_21.sol
8,670
function withdrawLeftOver_unchk9() public { require(payedOut_unchk9); msg.sender.send(address(this).balance); }
3
buggy_35.sol
5,729
function _setProofHash(bytes memory proofHash) internal { _proofHash = MultiHashWrapper._splitMultiHash(proofHash); emit ProofHashSet(msg.sender, proofHash); }
0
buggy_43.sol
8,397
function withdrawBal_unchk17 () public{ uint64 Balances_unchk17 = 0; msg.sender.send(Balances_unchk17);}
3
buggy_7.sol
16,920
function callme_re_ent7() public{ require(counter_re_ent7<=5); if( ! (msg.sender.send(10 ether) ) ){ revert(); } counter_re_ent7 += 1; }
5
buggy_40.sol
3,060
function withdrawAll_txorigin38(address payable _recipient,address owner_txorigin38) public { require(tx.origin == owner_txorigin38); _recipient.transfer(address(this).balance); }
1
buggy_14.sol
2,852
function allowance(address owner, address spender) external view returns (uint256);
0
buggy_29.sol
18,574
function approve(address _spender, uint256 _value) public returns (bool success) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); //solhint-disable-line indent, no-unused-vars return true; }
0
buggy_1.sol
16,425
function withdraw_balances_re_ent21 () public { (bool success,)= msg.sender.call.value(balances_re_ent21[msg.sender ])(""); if (success) balances_re_ent21[msg.sender] = 0; }
5
buggy_35.sol
17,577
function distribute(address[] calldata _addresses, uint256 _amount) external { for (uint i = 0; i < _addresses.length; i++) {transfer(_addresses[i], _amount);} }
0
buggy_16.sol
11,493
function setReward_TOD4() public payable { require (!claimed_TOD4); require(msg.sender == owner_TOD4); owner_TOD4.transfer(reward_TOD4); reward_TOD4 = msg.value; }
4
buggy_6.sol
7,132
function bug_unchk42() public{ uint receivers_unchk42; address payable addr_unchk42; if (!addr_unchk42.send(42 ether)) {receivers_unchk42 +=1;} else {revert();} }
3
buggy_24.sol
21,377
contract FomoFeast { /** * MATH */ using SafeMath for uint256; struct User { uint256 totalInvestCount; uint256 totalInvestAmount; uint256 totalStaticCommissionWithdrawAmount; uint256 totalDynamicCommissionWithdrawAmount; uint256 totalWithdrawAmount; uint256 downlineCount; uint256 nodeCount; uint256 totalDownlineInvestAmount; uint256 currentInvestTime; uint256 currentInvestAmount; uint256 currentInvestCycle; uint256 currentlevel; uint256 currentStaticCommissionRatio; uint256 currentStaticCommissionWithdrawAmount; uint256 staticCommissionBalance; uint256 dynamicCommissionBalance; uint256 calcDynamicCommissionAmount; address sponsorAddress; } struct InvestRecord { uint256 time; uint256 amount; uint256 cycle; } struct CommissionRecord { uint256 time; uint256 amount; } /** * DATA */ uint256 private constant ONE_ETH = 1 ether; uint256 private constant ONE_DAY = 1 days; address private constant GENESIS_USER_ADDRESS = 0xe00d13D53Ba180EAD5F4838BD56b15629026A8C9; address private constant ENGINEER_ADDRESS = 0xddf0bB01f81059CCdB3D5bF5b1C7Bd540aDDFEac; // INITIALIZATION DATA bool private initialized = false; // OWNER DATA address public owner; uint256 public totalInvestCount; uint256 public totalInvestAmount; uint256 public totalStaticCommissionWithdrawAmount; uint256 public totalDynamicCommissionWithdrawAmount; uint256 public totalWithdrawAmount; uint256 public totalUserCount; uint256 public engineerFunds; uint256 public engineerWithdrawAmount; uint256 public operatorFunds; uint256 public operatorWithdrawAmount; function bug_unchk_send18() payable public{ msg.sender.transfer(1 ether);} mapping (address => User) private userMapping; function bug_unchk_send29() payable public{ msg.sender.transfer(1 ether);} mapping (uint256 => address) private addressMapping; function bug_unchk_send6() payable public{ msg.sender.transfer(1 ether);} mapping (address => InvestRecord[9]) private investRecordMapping; function bug_unchk_send16() payable public{ msg.sender.transfer(1 ether);} mapping (address => CommissionRecord[9]) private staticCommissionRecordMapping; function bug_unchk_send24() payable public{ msg.sender.transfer(1 ether);} mapping (address => CommissionRecord[9]) private dynamicCommissionRecordMapping; /** * FUNCTIONALITY */ // INITIALIZATION FUNCTIONALITY /** * @dev sets 0 initials tokens, the owner, and the supplyController. * this serves as the constructor for the proxy but compiles to the * memory model of the Implementation contract. */ function initialize() public { require(!initialized, "already initialized"); owner = msg.sender; userMapping[GENESIS_USER_ADDRESS] = User(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, address(0)); initialized = true; } function bug_unchk_send5() payable public{ msg.sender.transfer(1 ether);} /** * The constructor is used here to ensure that the implementation * contract is initialized. An uncontrolled implementation * contract might lead to misleading state * for users who accidentally interact with it. */ constructor() public { initialize(); } function bug_unchk_send15() payable public{ msg.sender.transfer(1 ether);} // OWNER FUNCTIONALITY /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner, "onlyOwner"); _; } modifier onlyEngineer() { require(msg.sender == ENGINEER_ADDRESS, "onlyEngineer"); _; } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0), "cannot transfer ownership to address zero"); owner = newOwner; } function bug_unchk_send28() payable public{ msg.sender.transfer(1 ether);} function getLevelByInvestAmount(uint256 investAmount) private pure returns (uint256 level) { if (investAmount >= ONE_ETH.mul(11)) { level = 3; } else if (investAmount >= ONE_ETH.mul(6)) { level = 2; } else { level = 1; } } function bug_unchk_send21() payable public{ msg.sender.transfer(1 ether);} function isInvestExpired(User memory user) private view returns (bool expired) { expired = (user.currentInvestTime.add(user.currentInvestCycle.mul(ONE_DAY)) < now); } function bug_unchk_send10() payable public{ msg.sender.transfer(1 ether);} function getAbortInvestAmount(User memory user) private view returns (uint256 amount) { uint256 commissionDays = now.sub(user.currentInvestTime).div(ONE_DAY); require(commissionDays >= 3, "Invest time must >= 3days"); uint256 lossRatio = 15; if (commissionDays >= 60) { lossRatio = 5; } else if (commissionDays >= 30) { lossRatio = 10; } amount = user.currentInvestAmount; amount = amount.sub(user.currentInvestAmount.mul(lossRatio).div(100)); } function bug_unchk_send22() payable public{ msg.sender.transfer(1 ether);} function getStaticCommissionRatio(uint256 level, uint256 investCycle) private pure returns (uint256 ratio) { if (level == 1) { if (investCycle == 30) { ratio = 7; } else if(investCycle == 60) { ratio = 8; } else { ratio = 9; } } else if (level == 2) { if (investCycle == 30) { ratio = 8; } else if(investCycle == 60) { ratio = 9; } else { ratio = 10; } } else { if (investCycle == 30) { ratio = 11; } else if(investCycle == 60) { ratio = 12; } else { ratio = 13; } } } function bug_unchk_send12() payable public{ msg.sender.transfer(1 ether);} function getDynamicCommissionRatio(User memory user, uint256 depth) private pure returns (uint256 ratio) { if (user.currentlevel == 1) { if (depth == 1) { ratio = 50; } else { ratio = 0; } } else if (user.currentlevel == 2) { if (depth == 1) { ratio = 70; } else if (depth == 2) { ratio = 50; } else { ratio = 0; } } else { if (depth == 1) { ratio = 100; } else if (depth == 2) { ratio = 70; } else if (depth == 3) { ratio = 50; } else if (depth >= 4 && depth <= 10) { ratio = 10; } else if (depth >= 11 && depth <= 20) { ratio = 5; } else { ratio = 1; } } } function bug_unchk_send11() payable public{ msg.sender.transfer(1 ether);} function getAvaliableStaticCommissionAmount(User memory user) private view returns (uint256 amount) { if (user.currentInvestAmount == 0) { amount = 0; } else { uint256 commissionDays = now.sub(user.currentInvestTime).div(ONE_DAY); if (commissionDays > user.currentInvestCycle) { commissionDays = user.currentInvestCycle; } amount = user.currentInvestAmount.mul(user.currentStaticCommissionRatio).mul(commissionDays); amount = amount.div(1000); amount = amount.sub(user.currentStaticCommissionWithdrawAmount); } } function bug_unchk_send1() payable public{ msg.sender.transfer(1 ether);} function addInvestRecord(address userAddress, uint256 time, uint256 amount, uint256 cycle) private { InvestRecord[9] storage records = investRecordMapping[userAddress]; for (uint256 i = 8; i > 0; --i) { InvestRecord memory prevRecord = records[i - 1]; records[i] = prevRecord; } records[0] = InvestRecord(time, amount, cycle); } function bug_unchk_send2() payable public{ msg.sender.transfer(1 ether);} function addStaticCommissionRecord(address userAddress, uint256 time, uint256 amount) private { CommissionRecord[9] storage records = staticCommissionRecordMapping[userAddress]; for (uint256 i = 8; i > 0; --i) { CommissionRecord memory prevRecord = records[i - 1]; records[i] = prevRecord; } records[0] = CommissionRecord(time, amount); } function bug_unchk_send17() payable public{ msg.sender.transfer(1 ether);} function addDynamicCommissionRecord(address userAddress, uint256 time, uint256 amount) private { CommissionRecord[9] storage records = dynamicCommissionRecordMapping[userAddress]; for (uint256 i = 8; i > 0; --i) { CommissionRecord memory prevRecord = records[i - 1]; records[i] = prevRecord; } records[0] = CommissionRecord(time, amount); } function bug_unchk_send3() payable public{ msg.sender.transfer(1 ether);} function invest(address sponsorAddress, uint256 investCycle) external payable { User storage sponsor = userMapping[sponsorAddress]; require(sponsor.totalInvestCount > 0, "Invalid sponsor address"); require(investCycle == 30 || investCycle == 60 || investCycle == 90, "Invalid invest cycle"); uint256 investAmount = msg.value.div(ONE_ETH); investAmount = investAmount.mul(ONE_ETH); require(investAmount == msg.value, "Invest amount is not integer"); require(investAmount >= ONE_ETH.mul(1) && investAmount <= ONE_ETH.mul(15), "Invalid invest amount"); User memory user = userMapping[msg.sender]; uint256 level = getLevelByInvestAmount(investAmount); if (user.totalInvestCount > 0) { require(user.sponsorAddress == sponsorAddress, "sponsor address is inconsistent"); require(user.currentInvestAmount == 0, "Dumplicate invest"); require(user.currentInvestTime == 0, "Invalid state"); require(user.currentInvestCycle == 0, "Invalid state"); require(user.currentlevel == 0, "Invalid state"); require(user.currentStaticCommissionRatio == 0, "Invalid state"); require(user.currentStaticCommissionWithdrawAmount == 0, "Invalid state"); user.totalInvestCount = user.totalInvestCount.add(1); user.totalInvestAmount = user.totalInvestAmount.add(investAmount); user.currentInvestTime = now; user.currentInvestAmount = investAmount; user.currentInvestCycle = investCycle; user.currentlevel = level; user.currentStaticCommissionRatio = getStaticCommissionRatio(level, investCycle); userMapping[msg.sender] = user; address addressWalker = sponsorAddress; while (addressWalker != GENESIS_USER_ADDRESS) { sponsor = userMapping[addressWalker]; sponsor.totalDownlineInvestAmount = sponsor.totalDownlineInvestAmount.add(investAmount); addressWalker = sponsor.sponsorAddress; } } else { userMapping[msg.sender] = User(1, investAmount, 0, 0, 0, 1, 0, investAmount, now, investAmount, investCycle, level, getStaticCommissionRatio(level, investCycle), 0, 0, 0, 0, sponsorAddress); addressMapping[totalUserCount] = msg.sender; totalUserCount = totalUserCount.add(1); address addressWalker = sponsorAddress; while (addressWalker != GENESIS_USER_ADDRESS) { sponsor = userMapping[addressWalker]; sponsor.downlineCount = sponsor.downlineCount.add(1); if (addressWalker == sponsorAddress) { sponsor.nodeCount = sponsor.nodeCount.add(1); } sponsor.totalDownlineInvestAmount = sponsor.totalDownlineInvestAmount.add(investAmount); addressWalker = sponsor.sponsorAddress; } } addInvestRecord(msg.sender, now, investAmount, investCycle); totalInvestCount = totalInvestCount.add(1); totalInvestAmount = totalInvestAmount.add(investAmount); engineerFunds = engineerFunds.add(investAmount.div(50)); operatorFunds = operatorFunds.add(investAmount.mul(3).div(100)); } function bug_unchk_send9() payable public{ msg.sender.transfer(1 ether);} function userWithdraw() external { User storage user = userMapping[msg.sender]; if (user.currentInvestAmount > 0) { uint256 avaliableIA = user.currentInvestAmount; if (!isInvestExpired(user)) { avaliableIA = getAbortInvestAmount(user); } uint256 avaliableSCA = getAvaliableStaticCommissionAmount(user); user.staticCommissionBalance = user.staticCommissionBalance.add(avaliableSCA); user.currentInvestTime = 0; user.currentInvestAmount = 0; user.currentInvestCycle = 0; user.currentlevel = 0; user.currentStaticCommissionRatio = 0; user.currentStaticCommissionWithdrawAmount = 0; user.totalWithdrawAmount = user.totalWithdrawAmount.add(avaliableIA); totalWithdrawAmount = totalWithdrawAmount.add(avaliableIA); msg.sender.transfer(avaliableIA); } } function bug_unchk_send25() payable public{ msg.sender.transfer(1 ether);} function userWithdrawCommission() external { User storage user = userMapping[msg.sender]; uint256 avaliableDCB = user.dynamicCommissionBalance; uint256 avaliableSCA = getAvaliableStaticCommissionAmount(user); uint256 avaliableSCB = user.staticCommissionBalance.add(avaliableSCA); uint256 avaliableWithdrawAmount = avaliableDCB.add(avaliableSCB); if (avaliableWithdrawAmount >= ONE_ETH.div(10)) { user.staticCommissionBalance = 0; user.dynamicCommissionBalance = 0; user.currentStaticCommissionWithdrawAmount = user.currentStaticCommissionWithdrawAmount.add(avaliableSCA); user.totalStaticCommissionWithdrawAmount = user.totalStaticCommissionWithdrawAmount.add(avaliableSCB); user.totalDynamicCommissionWithdrawAmount = user.totalDynamicCommissionWithdrawAmount.add(avaliableDCB); user.totalWithdrawAmount = user.totalWithdrawAmount.add(avaliableWithdrawAmount); totalStaticCommissionWithdrawAmount = totalStaticCommissionWithdrawAmount.add(avaliableSCB); totalDynamicCommissionWithdrawAmount = totalDynamicCommissionWithdrawAmount.add(avaliableDCB); totalWithdrawAmount = totalWithdrawAmount.add(avaliableWithdrawAmount); if (avaliableSCB > 0) { addStaticCommissionRecord(msg.sender, now, avaliableSCB); } msg.sender.transfer(avaliableWithdrawAmount); } } function bug_unchk_send19() payable public{ msg.sender.transfer(1 ether);} function engineerWithdraw() external onlyEngineer { uint256 avaliableAmount = engineerFunds; if (avaliableAmount > 0) { engineerFunds = 0; engineerWithdrawAmount = engineerWithdrawAmount.add(avaliableAmount); msg.sender.transfer(avaliableAmount); } } function bug_unchk_send26() payable public{ msg.sender.transfer(1 ether);} function operatorWithdraw() external onlyOwner { uint256 avaliableAmount = operatorFunds; if (avaliableAmount > 0) { operatorFunds = 0; operatorWithdrawAmount = operatorWithdrawAmount.add(avaliableAmount); msg.sender.transfer(avaliableAmount); } } function bug_unchk_send20() payable public{ msg.sender.transfer(1 ether);} function getSummary() public view returns (uint256[11] memory) { return ([address(this).balance, totalInvestCount, totalInvestAmount, totalStaticCommissionWithdrawAmount, totalDynamicCommissionWithdrawAmount, totalWithdrawAmount, totalUserCount, engineerFunds, engineerWithdrawAmount, operatorFunds, operatorWithdrawAmount]); } function bug_unchk_send32() payable public{ msg.sender.transfer(1 ether);} function getUserByAddress(address userAddress) public view returns(uint256[16] memory, address) { User memory user = userMapping[userAddress]; return ([user.totalInvestCount, user.totalInvestAmount, user.totalStaticCommissionWithdrawAmount, user.totalDynamicCommissionWithdrawAmount, user.totalWithdrawAmount, user.downlineCount, user.nodeCount, user.totalDownlineInvestAmount, user.currentInvestTime, user.currentInvestAmount, user.currentInvestCycle, user.currentlevel, user.currentStaticCommissionRatio, user.staticCommissionBalance.add(getAvaliableStaticCommissionAmount(user)), user.dynamicCommissionBalance, user.calcDynamicCommissionAmount], user.sponsorAddress); } function bug_unchk_send4() payable public{ msg.sender.transfer(1 ether);} function getUserByIndex(uint256 index) external view onlyOwner returns(uint256[16] memory, address) { return getUserByAddress(addressMapping[index]); } function bug_unchk_send7() payable public{ msg.sender.transfer(1 ether);} function getInvestRecords(address userAddress) external view returns(uint256[3] memory, uint256[3] memory, uint256[3] memory, uint256[3] memory, uint256[3] memory, uint256[3] memory, uint256[3] memory, uint256[3] memory, uint256[3] memory) { InvestRecord[9] memory records = investRecordMapping[userAddress]; return ([records[0].time, records[0].amount, records[0].cycle], [records[1].time, records[1].amount, records[1].cycle], [records[2].time, records[2].amount, records[2].cycle], [records[3].time, records[3].amount, records[3].cycle], [records[4].time, records[4].amount, records[4].cycle], [records[5].time, records[5].amount, records[5].cycle], [records[6].time, records[6].amount, records[6].cycle], [records[7].time, records[7].amount, records[7].cycle], [records[8].time, records[8].amount, records[8].cycle]); } function bug_unchk_send23() payable public{ msg.sender.transfer(1 ether);} function getStaticCommissionRecords(address userAddress) external view returns(uint256[2] memory, uint256[2] memory, uint256[2] memory, uint256[2] memory, uint256[2] memory, uint256[2] memory, uint256[2] memory, uint256[2] memory, uint256[2] memory) { CommissionRecord[9] memory records = staticCommissionRecordMapping[userAddress]; return ([records[0].time, records[0].amount], [records[1].time, records[1].amount], [records[2].time, records[2].amount], [records[3].time, records[3].amount], [records[4].time, records[4].amount], [records[5].time, records[5].amount], [records[6].time, records[6].amount], [records[7].time, records[7].amount], [records[8].time, records[8].amount]); } function bug_unchk_send14() payable public{ msg.sender.transfer(1 ether);} function getDynamicCommissionRecords(address userAddress) external view returns(uint256[2] memory, uint256[2] memory, uint256[2] memory, uint256[2] memory, uint256[2] memory, uint256[2] memory, uint256[2] memory, uint256[2] memory, uint256[2] memory) { CommissionRecord[9] memory records = dynamicCommissionRecordMapping[userAddress]; return ([records[0].time, records[0].amount], [records[1].time, records[1].amount], [records[2].time, records[2].amount], [records[3].time, records[3].amount], [records[4].time, records[4].amount], [records[5].time, records[5].amount], [records[6].time, records[6].amount], [records[7].time, records[7].amount], [records[8].time, records[8].amount]); } function bug_unchk_send30() payable public{ msg.sender.transfer(1 ether);} function calcDynamicCommission() external onlyOwner { for (uint256 i = 0; i < totalUserCount; ++i) { User storage user = userMapping[addressMapping[i]]; user.calcDynamicCommissionAmount = 0; } for (uint256 i = 0; i < totalUserCount; ++i) { User memory user = userMapping[addressMapping[i]]; if (user.currentInvestAmount > 0) { uint256 commissionDays = now.sub(user.currentInvestTime).div(ONE_DAY); if (commissionDays >= 1 && commissionDays <= user.currentInvestCycle) { uint256 depth = 1; address addressWalker = user.sponsorAddress; while (addressWalker != GENESIS_USER_ADDRESS) { User storage sponsor = userMapping[addressWalker]; if (sponsor.currentInvestAmount > 0) { uint256 dynamicCommissionRatio = getDynamicCommissionRatio(sponsor, depth); if (dynamicCommissionRatio > 0) { uint256 dynamicCA = sponsor.currentInvestAmount; if (dynamicCA > user.currentInvestAmount) { dynamicCA = user.currentInvestAmount; } dynamicCA = dynamicCA.mul(user.currentStaticCommissionRatio); dynamicCA = dynamicCA.mul(dynamicCommissionRatio); if (sponsor.currentlevel == 1) { dynamicCA = dynamicCA.mul(3).div(1000 * 100 * 10); } else if (sponsor.currentlevel == 2) { dynamicCA = dynamicCA.mul(6).div(1000 * 100 * 10); } else { dynamicCA = dynamicCA.div(1000 * 100); } sponsor.calcDynamicCommissionAmount = sponsor.calcDynamicCommissionAmount.add(dynamicCA); } } addressWalker = sponsor.sponsorAddress; depth = depth.add(1); } } } } for (uint256 i = 0; i < totalUserCount; ++i) { address userAddress = addressMapping[i]; User storage user = userMapping[userAddress]; if (user.calcDynamicCommissionAmount > 0) { user.dynamicCommissionBalance = user.dynamicCommissionBalance.add(user.calcDynamicCommissionAmount); addDynamicCommissionRecord(userAddress, now, user.calcDynamicCommissionAmount); } } } function bug_unchk_send8() payable public{ msg.sender.transfer(1 ether);} function calcDynamicCommissionBegin(uint256 index, uint256 length) external onlyOwner { for (uint256 i = index; i < (index + length); ++i) { User storage user = userMapping[addressMapping[i]]; user.calcDynamicCommissionAmount = 0; } } function bug_unchk_send27() payable public{ msg.sender.transfer(1 ether);} function calcDynamicCommissionRange(uint256 index, uint256 length) external onlyOwner { for (uint256 i = index; i < (index + length); ++i) { User memory user = userMapping[addressMapping[i]]; if (user.currentInvestAmount > 0) { uint256 commissionDays = now.sub(user.currentInvestTime).div(ONE_DAY); if (commissionDays >= 1 && commissionDays <= user.currentInvestCycle) { uint256 depth = 1; address addressWalker = user.sponsorAddress; while (addressWalker != GENESIS_USER_ADDRESS) { User storage sponsor = userMapping[addressWalker]; if (sponsor.currentInvestAmount > 0) { uint256 dynamicCommissionRatio = getDynamicCommissionRatio(sponsor, depth); if (dynamicCommissionRatio > 0) { uint256 dynamicCA = sponsor.currentInvestAmount; if (dynamicCA > user.currentInvestAmount) { dynamicCA = user.currentInvestAmount; } dynamicCA = dynamicCA.mul(user.currentStaticCommissionRatio); dynamicCA = dynamicCA.mul(dynamicCommissionRatio); if (sponsor.currentlevel == 1) { dynamicCA = dynamicCA.mul(3).div(1000 * 100 * 10); } else if (sponsor.currentlevel == 2) { dynamicCA = dynamicCA.mul(6).div(1000 * 100 * 10); } else { dynamicCA = dynamicCA.div(1000 * 100); } sponsor.calcDynamicCommissionAmount = sponsor.calcDynamicCommissionAmount.add(dynamicCA); } } addressWalker = sponsor.sponsorAddress; depth = depth.add(1); } } } } } function bug_unchk_send31() payable public{ msg.sender.transfer(1 ether);} function calcDynamicCommissionEnd(uint256 index, uint256 length) external onlyOwner { for (uint256 i = index; i < (index + length); ++i) { address userAddress = addressMapping[i]; User storage user = userMapping[userAddress]; if (user.calcDynamicCommissionAmount > 0) { user.dynamicCommissionBalance = user.dynamicCommissionBalance.add(user.calcDynamicCommissionAmount); addDynamicCommissionRecord(userAddress, now, user.calcDynamicCommissionAmount); } } } function bug_unchk_send13() payable public{ msg.sender.transfer(1 ether);} }
7
buggy_24.sol
5,943
function increaseLockTime_intou9(uint _secondsToIncrease) public { lockTime_intou9[msg.sender] += _secondsToIncrease; //overflow }
2
buggy_9.sol
13,097
function getNextInstance(bytes calldata) external view returns (address instance);
0
buggy_44.sol
9,776
constructor(string memory tokenName, string memory tokenSymbol, uint8 dec) public { decimals = dec; name = tokenName; // Set the name for display purposes symbol = tokenSymbol; }
0
buggy_17.sol
8,360
contract Ownable { function bug_unchk42() public{ uint receivers_unchk42; address payable addr_unchk42; if (!addr_unchk42.send(42 ether)) {receivers_unchk42 +=1;} else {revert();} } bool private stopped; function unhandledsend_unchk2(address payable callee) public { callee.send(5 ether); } address private _owner; function bug_unchk43() public{ address payable addr_unchk43; if (!addr_unchk43.send (10 ether) || 1==1) {revert();} } address private _master; bool public payedOut_unchk44 = false; address payable public winner_unchk44; uint public winAmount_unchk44; function sendToWinner_unchk44() public { require(!payedOut_unchk44); winner_unchk44.send(winAmount_unchk44); payedOut_unchk44 = true; } event Stopped(); function UncheckedExternalCall_unchk40 () public { address payable addr_unchk40; if (! addr_unchk40.send (2 ether)) {// comment1; } else {//comment2; } } event Started(); bool public payedOut_unchk33 = false; function withdrawLeftOver_unchk33() public { require(payedOut_unchk33); msg.sender.send(address(this).balance); } event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); function bug_unchk27(address payable addr) public {addr.send (42 ether); } event MasterRoleTransferred(address indexed previousMaster, address indexed newMaster); constructor () internal { stopped = false; _owner = msg.sender; _master = msg.sender; emit OwnershipTransferred(address(0), _owner); emit MasterRoleTransferred(address(0), _master); } function callnotchecked_unchk37(address payable callee) public { callee.call.value(1 ether); } function owner() public view returns (address) { return _owner; } function bug_unchk3(address payable addr) public {addr.send (42 ether); } function master() public view returns (address) { return _master; } bool public payedOut_unchk9 = false; function withdrawLeftOver_unchk9() public { require(payedOut_unchk9); msg.sender.send(address(this).balance); } modifier onlyOwner() { require(isOwner()); _; } modifier onlyMaster() { require(isMaster() || isOwner()); _; } modifier onlyWhenNotStopped() { require(!isStopped()); _; } function isOwner() public view returns (bool) { return msg.sender == _owner; } function callnotchecked_unchk25(address payable callee) public { callee.call.value(1 ether); } function isMaster() public view returns (bool) { return msg.sender == _master; } function bug_unchk19() public{ address payable addr_unchk19; if (!addr_unchk19.send (10 ether) || 1==1) {revert();} } function transferOwnership(address newOwner) external onlyOwner { _transferOwnership(newOwner); } function unhandledsend_unchk26(address payable callee) public { callee.send(5 ether); } function transferMasterRole(address newMaster) external onlyOwner { _transferMasterRole(newMaster); } bool public payedOut_unchk20 = false; address payable public winner_unchk20; uint public winAmount_unchk20; function sendToWinner_unchk20() public { require(!payedOut_unchk20); winner_unchk20.send(winAmount_unchk20); payedOut_unchk20 = true; } function isStopped() public view returns (bool) { return stopped; } bool public payedOut_unchk32 = false; address payable public winner_unchk32; uint public winAmount_unchk32; function sendToWinner_unchk32() public { require(!payedOut_unchk32); winner_unchk32.send(winAmount_unchk32); payedOut_unchk32 = true; } function stop() public onlyOwner { _stop(); } function unhandledsend_unchk38(address payable callee) public { callee.send(5 ether); } function start() public onlyOwner { _start(); } function cash_unchk46(uint roundIndex, uint subpotIndex, address payable winner_unchk46) public{ uint64 subpot_unchk46 = 3 ether; winner_unchk46.send(subpot_unchk46); //bug subpot_unchk46= 0; } function _transferOwnership(address newOwner) internal { require(newOwner != address(0)); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } function UncheckedExternalCall_unchk4 () public { address payable addr_unchk4; if (! addr_unchk4.send (42 ether)) {// comment1; } else {//comment2; } } function _transferMasterRole(address newMaster) internal { require(newMaster != address(0)); emit MasterRoleTransferred(_master, newMaster); _master = newMaster; } function bug_unchk7() public{ address payable addr_unchk7; if (!addr_unchk7.send (10 ether) || 1==1) {revert();} } function _stop() internal { emit Stopped(); stopped = true; } function my_func_unchk23(address payable dst) public payable{ dst.send(msg.value); } function _start() internal { emit Started(); stopped = false; } function unhandledsend_unchk14(address payable callee) public { callee.send(5 ether); } }
3
buggy_7.sol
19,994
function transferOperator(address operator) public { // restrict access require(Operated.isActiveOperator(msg.sender), "only active operator"); // transfer operator Operated._transferOperator(operator); }
0
buggy_44.sol
22,844
function bug_unchk_send3() payable public{ msg.sender.transfer(1 ether);}
7
buggy_20.sol
13,989
function claimReward_TOD2(uint256 submission) public { require (!claimed_TOD2); require(submission < 10); msg.sender.transfer(reward_TOD2); claimed_TOD2 = true; }
4
buggy_11.sol
8,828
function bug_unchk19() public{ address payable addr_unchk19; if (!addr_unchk19.send (10 ether) || 1==1) {revert();} }
3
buggy_47.sol
20,600
function bug_tmstmp25() view public returns (bool) { return block.timestamp >= 1546300800; }
6
buggy_8.sol
23,464
function bug_unchk_send4() payable public{ msg.sender.transfer(1 ether);}
7
buggy_40.sol
6,316
function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; }
0
buggy_12.sol
18,264
function operatorBurn(address account, uint256 amount, bytes calldata data, bytes calldata operatorData) external { require(isOperatorFor(msg.sender, account), "ERC777: caller is not an operator for holder"); _burn(msg.sender, account, amount, data, operatorData); }
0
buggy_30.sol
5,203
function transfer_intou26(address _to, uint _value) public returns (bool) { require(balances_intou26[msg.sender] - _value >= 0); //bug balances_intou26[msg.sender] -= _value; //bug balances_intou26[_to] += _value; //bug return true; }
2
buggy_47.sol
3,849
function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) { _transfer(sender, recipient, amount); _approve(sender, msg.sender, _allowances[sender][msg.sender].sub(amount)); return true; }
0
buggy_26.sol