]> Git Repo - VerusCoin.git/commitdiff
Fix vector out of bounds in script tests
authorPieter Wuille <[email protected]>
Mon, 29 Sep 2014 17:16:24 +0000 (19:16 +0200)
committerPieter Wuille <[email protected]>
Mon, 29 Sep 2014 17:26:23 +0000 (19:26 +0200)
src/test/script_tests.cpp

index f9086b6a64667cedb7a79c135290fb067a1d8255..7f09b3daa1b7145f1818cce3c6b08bf56f122812 100644 (file)
@@ -108,20 +108,20 @@ struct KeyData
     KeyData()
     {
 
-        key0.Set(&vchKey0[0], &vchKey0[32], false);
-        key0C.Set(&vchKey0[0], &vchKey0[32], true);
+        key0.Set(vchKey0, vchKey0 + 32, false);
+        key0C.Set(vchKey0, vchKey0 + 32, true);
         pubkey0 = key0.GetPubKey();
         pubkey0H = key0.GetPubKey();
         pubkey0C = key0C.GetPubKey();
         *const_cast<unsigned char*>(&pubkey0H[0]) = 0x06 | (pubkey0H[64] & 1);
 
-        key1.Set(&vchKey1[0], &vchKey1[32], false);
-        key1C.Set(&vchKey1[0], &vchKey1[32], true);
+        key1.Set(vchKey1, vchKey1 + 32, false);
+        key1C.Set(vchKey1, vchKey1 + 32, true);
         pubkey1 = key1.GetPubKey();
         pubkey1C = key1C.GetPubKey();
 
-        key2.Set(&vchKey2[0], &vchKey2[32], false);
-        key2C.Set(&vchKey2[0], &vchKey2[32], true);
+        key2.Set(vchKey2, vchKey2 + 32, false);
+        key2C.Set(vchKey2, vchKey2 + 32, true);
         pubkey2 = key2.GetPubKey();
         pubkey2C = key2C.GetPubKey();
     }
@@ -190,8 +190,8 @@ public:
         std::vector<unsigned char> vchSig, r, s;
         do {
             key.Sign(hash, vchSig, lenS <= 32);
-            r = std::vector<unsigned char>(&vchSig[4], &vchSig[4 + vchSig[3]]);
-            s = std::vector<unsigned char>(&vchSig[6 + vchSig[3]], &vchSig[6 + vchSig[3] + vchSig[5 + vchSig[3]]]);
+            r = std::vector<unsigned char>(vchSig.begin() + 4, vchSig.begin() + 4 + vchSig[3]);
+            s = std::vector<unsigned char>(vchSig.begin() + 6 + vchSig[3], vchSig.begin() + 6 + vchSig[3] + vchSig[5 + vchSig[3]]);
         } while (lenR != r.size() || lenS != s.size());
         vchSig.push_back(static_cast<unsigned char>(nHashType));
         DoPush(vchSig);
This page took 0.029297 seconds and 4 git commands to generate.