From 68af7d02cf63eb3d2ed015013d245fe5d3aadbd1 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Mon, 29 Sep 2014 19:16:24 +0200 Subject: [PATCH] Fix vector out of bounds in script tests --- src/test/script_tests.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/test/script_tests.cpp b/src/test/script_tests.cpp index f9086b6a646..7f09b3daa1b 100644 --- a/src/test/script_tests.cpp +++ b/src/test/script_tests.cpp @@ -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(&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 vchSig, r, s; do { key.Sign(hash, vchSig, lenS <= 32); - r = std::vector(&vchSig[4], &vchSig[4 + vchSig[3]]); - s = std::vector(&vchSig[6 + vchSig[3]], &vchSig[6 + vchSig[3] + vchSig[5 + vchSig[3]]]); + r = std::vector(vchSig.begin() + 4, vchSig.begin() + 4 + vchSig[3]); + s = std::vector(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(nHashType)); DoPush(vchSig);