Browse Source

Implement VestedToken bug mitigation #3

Manuel Araoz 8 years ago
parent
commit
7100e30bed
1 changed files with 5 additions and 0 deletions
  1. 5 0
      contracts/token/VestedToken.sol

+ 5 - 0
contracts/token/VestedToken.sol

@@ -8,6 +8,9 @@ import "./LimitedTransferToken.sol";
  * @dev Tokens that can be vested for a group of addresses.
  */
 contract VestedToken is StandardToken, LimitedTransferToken {
+
+  uint256 MAX_GRANTS_PER_ADDRESS = 20;
+
   struct TokenGrant {
     address granter;     // 20 bytes
     uint256 value;       // 32 bytes
@@ -45,6 +48,8 @@ contract VestedToken is StandardToken, LimitedTransferToken {
       throw;
     }
 
+    if (tokenGrantsCount(_to) > MAX_GRANTS_PER_ADDRESS) throw;   // To prevent a user being spammed and have his balance locked (out of gas attack when calculating vesting).
+
     uint count = grants[_to].push(
                 TokenGrant(
                   _revokable ? msg.sender : 0, // avoid storing an extra 20 bytes when it is non-revokable