smartbugs-curated/dataset/arithmetic/insecure_transfer.sol

22 lines
584 B
Solidity

/*
* @source: https://consensys.github.io/smart-contract-best-practices/known_attacks/#front-running-aka-transaction-ordering-dependence
* @author: consensys
* @vulnerable_at_lines: 18
*/
pragma solidity ^0.4.0;
contract IntegerOverflowAdd {
mapping (address => uint256) public balanceOf;
// INSECURE
function transfer(address _to, uint256 _value) public{
/* Check if sender has balance */
require(balanceOf[msg.sender] >= _value);
balanceOf[msg.sender] -= _value;
// <yes> <report> ARITHMETIC
balanceOf[_to] += _value;
}
}