aboutsummaryrefslogtreecommitdiff
path: root/src/key.h
diff options
context:
space:
mode:
authorLuke Dashjr <luke-jr+git@utopios.org>2012-03-16 16:44:00 -0400
committerLuke Dashjr <luke-jr+git@utopios.org>2012-03-16 16:44:00 -0400
commit78b9d2de40144e6f420518bcdf62168855546ded (patch)
treeb1f761e093bc60f82c793f3144f226d0d7e666fb /src/key.h
parent27960a36de879634ee8c491d0f4fe8160e8a4f75 (diff)
parent91aadbdacf9a3111da76eb831ea36d6827e1d6fc (diff)
downloadbitcoin-78b9d2de40144e6f420518bcdf62168855546ded.tar.xz
Merge branch '0.4.x' into 0.5.0.x
Conflicts: contrib/Bitcoin.app/Contents/Info.plist doc/README doc/README_windows.txt share/setup.nsi src/serialize.h
Diffstat (limited to 'src/key.h')
-rw-r--r--src/key.h13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/key.h b/src/key.h
index f20acb3348..b1869505fb 100644
--- a/src/key.h
+++ b/src/key.h
@@ -290,13 +290,14 @@ public:
bool Sign(uint256 hash, std::vector<unsigned char>& vchSig)
{
- vchSig.clear();
- unsigned char pchSig[10000];
- unsigned int nSize = 0;
- if (!ECDSA_sign(0, (unsigned char*)&hash, sizeof(hash), pchSig, &nSize, pkey))
+ unsigned int nSize = ECDSA_size(pkey);
+ vchSig.resize(nSize); // Make sure it is big enough
+ if (!ECDSA_sign(0, (unsigned char*)&hash, sizeof(hash), &vchSig[0], &nSize, pkey))
+ {
+ vchSig.clear();
return false;
- vchSig.resize(nSize);
- memcpy(&vchSig[0], pchSig, nSize);
+ }
+ vchSig.resize(nSize); // Shrink to fit actual size
return true;
}