as suggested by /u/izqui9 here https://www.reddit.com/r/ethereum/comments/63s917/worrysome_bug_exploit_with_erc20_token/dfwmhc3/ Attack description: https://blog.golemproject.net/how-to-find-10m-by-just-reading-blockchain-6ae9d39fcd95
35 lines
731 B
Solidity
35 lines
731 B
Solidity
pragma solidity ^0.4.8;
|
|
|
|
|
|
import './ERC20Basic.sol';
|
|
import '../SafeMath.sol';
|
|
|
|
|
|
/*
|
|
* Basic token
|
|
* Basic version of StandardToken, with no allowances
|
|
*/
|
|
contract BasicToken is ERC20Basic, SafeMath {
|
|
|
|
mapping(address => uint) balances;
|
|
|
|
/*
|
|
* Fix for the ERC20 short address attack
|
|
*/
|
|
modifier onlyPayloadSize(uint size) {
|
|
assert(msg.data.length == size + 4);
|
|
_;
|
|
}
|
|
|
|
function transfer(address _to, uint _value) onlyPayloadSize(2 * 32) {
|
|
balances[msg.sender] = safeSub(balances[msg.sender], _value);
|
|
balances[_to] = safeAdd(balances[_to], _value);
|
|
Transfer(msg.sender, _to, _value);
|
|
}
|
|
|
|
function balanceOf(address _owner) constant returns (uint balance) {
|
|
return balances[_owner];
|
|
}
|
|
|
|
}
|