Fix coinbase out-of-bounds check
[novacoin.git] / src / main.cpp
index e957e63..332832e 100644 (file)
@@ -76,10 +76,6 @@ const string strMessageMagic = "NovaCoin Signed Message:\n";
 int64 nTransactionFee = MIN_TX_FEE;
 bool fStakeUsePooledKeys = false;
 
-// Used during database migration.
-bool fDisableSignatureChecking = false;
-
-
 //////////////////////////////////////////////////////////////////////////////
 //
 // dispatching functions
@@ -2266,7 +2262,8 @@ bool CBlock::AcceptBlock()
 
     // Enforce rule that the coinbase starts with serialized block height
     CScript expect = CScript() << nHeight;
-    if (!std::equal(expect.begin(), expect.end(), vtx[0].vin[0].scriptSig.begin()))
+    if (vtx[0].vin[0].scriptSig.size() < expect.size() ||
+        !std::equal(expect.begin(), expect.end(), vtx[0].vin[0].scriptSig.begin()))
         return DoS(100, error("AcceptBlock() : block height mismatch in coinbase"));
 
     // Write block to history file
@@ -2871,7 +2868,7 @@ void PrintBlockTree()
     }
 }
 
-bool LoadExternalBlockFile(FILE* fileIn, ExternalBlockFileProgress *progress)
+bool LoadExternalBlockFile(FILE* fileIn)
 {
     int64 nStart = GetTimeMillis();
 
@@ -2920,8 +2917,6 @@ bool LoadExternalBlockFile(FILE* fileIn, ExternalBlockFileProgress *progress)
                         nPos += 4 + nSize;
                     }
                 }
-                if (progress != NULL)
-                    (*progress)(4 + nSize);
             }
         }
         catch (std::exception &e) {