changeset 2823:700ef388ed93 draft

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
author Luke Dashjr <luke-jr+git@utopios.org>
date Fri, 16 Mar 2012 16:44:00 -0400
parents 12fdd3ec6c82 (current diff) 94e5029b345f (diff)
children 288dba7c3905 a5e096efce59
files doc/README doc/README_windows.txt share/setup.nsi src/key.h src/main.cpp src/main.h src/serialize.h
diffstat 2 files changed, 8 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/key.h
+++ b/src/key.h
@@ -290,13 +290,14 @@
 
     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;
     }
 
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1959,7 +1959,7 @@
         }
 
         // Ask the first connected node for block updates
-        static int nAskedForBlocks;
+        static int nAskedForBlocks = 0;
         if (!pfrom->fClient &&
             (pfrom->nVersion < 32000 || pfrom->nVersion >= 32400) &&
              (nAskedForBlocks < 1 || vNodes.size() <= 1))