diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2014-09-29 19:16:24 +0200 |
---|---|---|
committer | Pieter Wuille <pieter.wuille@gmail.com> | 2014-09-29 19:26:23 +0200 |
commit | 68af7d02cf63eb3d2ed015013d245fe5d3aadbd1 (patch) | |
tree | 0939f70a0dfdf19f2e958ab9d579da476db9b18f /src/test/script_tests.cpp | |
parent | 2884b9a4aef53245798e4f50793eb3e70aa73a6d (diff) |
Fix vector out of bounds in script tests
Diffstat (limited to 'src/test/script_tests.cpp')
-rw-r--r-- | src/test/script_tests.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/test/script_tests.cpp b/src/test/script_tests.cpp index f9086b6a64..7f09b3daa1 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<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); |