limits
authorforrest <forrest@470744a7-cac9-478e-843e-5ec1b25c69e8>
Thu, 14 Jul 2011 13:19:25 +0000 (13:19 +0000)
committerforrest <forrest@470744a7-cac9-478e-843e-5ec1b25c69e8>
Thu, 14 Jul 2011 13:19:25 +0000 (13:19 +0000)
git-svn-id: svn://forre.st/p2pool@1386 470744a7-cac9-478e-843e-5ec1b25c69e8

p2pool/data.py
p2pool/main.py

index 593fb0f..219becc 100644 (file)
@@ -138,6 +138,9 @@ class Share(object):
                     raise ValueError('invalid merkle_branch and other_txs')
             merkle_branch = new_merkle_branch
         
+        if len(merkle_branch) > 16:
+            raise ValueError('merkle_branch too long!')
+        
         self.header = header
         self.share_info = share_info
         self.merkle_branch = merkle_branch
@@ -149,9 +152,16 @@ class Share(object):
         self.new_script = self.share_info['new_script']
         self.subsidy = self.share_info['subsidy']
         
+        if len(self.new_script) > 100:
+            raise ValueError('new_script too long!')
+        
         self.previous_hash = self.previous_share_hash = self.share_data['previous_share_hash']
         self.previous_shares_hash = self.share_data['previous_shares_hash']
         self.target2 = self.share_data['target2']
+        self.nonce = self.share_data['nonce']
+        
+        if len(self.nonce) > 20:
+            raise ValueError('nonce too long!')
         
         self.hash = bitcoin_data.block_header_type.hash256(header)
         
index b416220..81f5395 100644 (file)
@@ -348,6 +348,7 @@ def main(args):
         
         def compute(state):
             extra_txs = [tx for tx in tx_pool.itervalues() if tx.is_good()]
+            # XXX limit to merkle_branch and block max size - 1000000 byte
             generate_tx = p2pool.generate_transaction(
                 tracker=tracker,
                 previous_share_hash=state['best_share_hash'],