Skip to content

Commit

Permalink
Merge pull request OpenZeppelin#188 from jdetychey/patch-3
Browse files Browse the repository at this point in the history
fix for short address attack
  • Loading branch information
maraoz authored Apr 11, 2017
2 parents d1f63f5 + 5d75264 commit 22018fd
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion contracts/token/BasicToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,15 @@ contract BasicToken is ERC20Basic, SafeMath {

mapping(address => uint) balances;

function transfer(address _to, uint _value) {
/*
* 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);
Expand Down

0 comments on commit 22018fd

Please sign in to comment.