Commit 22018fd3 by Manuel Aráoz Committed by GitHub

Merge pull request #188 from jdetychey/patch-3

fix for short address attack
parents d1f63f5c 5d75264f
...@@ -13,7 +13,15 @@ contract BasicToken is ERC20Basic, SafeMath { ...@@ -13,7 +13,15 @@ contract BasicToken is ERC20Basic, SafeMath {
mapping(address => uint) balances; 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[msg.sender] = safeSub(balances[msg.sender], _value);
balances[_to] = safeAdd(balances[_to], _value); balances[_to] = safeAdd(balances[_to], _value);
Transfer(msg.sender, _to, _value); Transfer(msg.sender, _to, _value);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment