From: Sunny King Date: Thu, 12 Jul 2012 15:27:55 +0000 (+0100) Subject: PPCoin: RPC 'makekeypair' limits loop to avoid hang X-Git-Tag: v0.4.0-unstable~130 X-Git-Url: https://git.novaco.in/?p=novacoin.git;a=commitdiff_plain;h=34b67676bb113a79f5f3784dd41541ea1d174729;hp=09f2a990950512cbe418526d91838887a0dded2a PPCoin: RPC 'makekeypair' limits loop to avoid hang --- diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp index 60c5449..70b608a 100644 --- a/src/bitcoinrpc.cpp +++ b/src/bitcoinrpc.cpp @@ -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;