Skip to content

Instantly share code, notes, and snippets.

@michielmulders
Created April 27, 2018 20:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michielmulders/cd756096a1aa046d546ae639d4be5c04 to your computer and use it in GitHub Desktop.
Save michielmulders/cd756096a1aa046d546ae639d4be5c04 to your computer and use it in GitHub Desktop.
BatchOverflow Bug ERC20 - Not using SafeMath Lib
function batchTransfer(address[] _receivers, uint256 _value) public whenNotPaused returns (bool) {
uint cnt = _receivers.length;
uint256 amount = uint256(cnt) * _value;
require(cnt > 0 && cnt <= 20);
require(_value > 0 && balances[msg.sender] >= amount);
balances[msg.sender] = balances[msg.sender].sub(amount);
for (uint i = 0; i < cnt; i++) {
balances[_receivers[i]] = balances[_receivers[i]].add(_value);
Transfer(msg.sender, _receivers[i], _value);
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment