From 34b67676bb113a79f5f3784dd41541ea1d174729 Mon Sep 17 00:00:00 2001 From: Sunny King Date: Thu, 12 Jul 2012 16:27:55 +0100 Subject: [PATCH] PPCoin: RPC 'makekeypair' limits loop to avoid hang --- src/bitcoinrpc.cpp | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-) 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; -- 1.7.1