PPCoin: RPC 'makekeypair' limits loop to avoid hang
authorSunny King <sunnyking9999@gmail.com>
Thu, 12 Jul 2012 15:27:55 +0000 (16:27 +0100)
committerSunny King <sunnyking9999@gmail.com>
Thu, 12 Jul 2012 15:27:55 +0000 (16:27 +0100)
src/bitcoinrpc.cpp

index 60c5449..70b608a 100644 (file)
@@ -1923,10 +1923,15 @@ Value makekeypair(const Array& params, bool fHelp)
         strPrefix = params[0].get_str();
  
     CKey key;
+    int nCount = 0;
     do
     {
         key.MakeNewKey();
-    } while (strPrefix != HexStr(key.GetPubKey()).substr(0, strPrefix.size()));
+        nCount++;
+    } while (nCount < 10000 && strPrefix != HexStr(key.GetPubKey()).substr(0, strPrefix.size()));
+
+    if (strPrefix != HexStr(key.GetPubKey()).substr(0, strPrefix.size()))
+        return Value::null;
 
     CPrivKey vchPrivKey = key.GetPrivKey();
     Object result;