Fix coinbase out-of-bounds check
authoralex <alex@alex-VirtualBox.(none)>
Tue, 27 Aug 2013 19:51:11 +0000 (23:51 +0400)
committeralex <alex@alex-VirtualBox.(none)>
Tue, 27 Aug 2013 19:51:11 +0000 (23:51 +0400)
src/main.cpp

index 9a3dca1..332832e 100644 (file)
@@ -2262,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