aboutsummaryrefslogtreecommitdiff
path: root/src/rpcdump.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <[email protected]>2014-01-28 09:38:10 +0100
committerWladimir J. van der Laan <[email protected]>2014-01-28 09:57:57 +0100
commitc7f933259623c87a9a3d116cc9bcfd75deb497da (patch)
tree9975aa42123c6702a67734f3b63fb34cce42f05a /src/rpcdump.cpp
parentMerge pull request #3589 from Diapolo/english-reason (diff)
downloaddiscoin-c7f933259623c87a9a3d116cc9bcfd75deb497da.tar.xz
discoin-c7f933259623c87a9a3d116cc9bcfd75deb497da.zip
Add check for valid keys in `importprivkey`
The base58 armoring was checked, but not the resulting private key, which could be out of range. Fix this by adding a check.
Diffstat (limited to 'src/rpcdump.cpp')
-rw-r--r--src/rpcdump.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/rpcdump.cpp b/src/rpcdump.cpp
index 726f23011..f66dbc0eb 100644
--- a/src/rpcdump.cpp
+++ b/src/rpcdump.cpp
@@ -101,9 +101,11 @@ Value importprivkey(const Array& params, bool fHelp)
CBitcoinSecret vchSecret;
bool fGood = vchSecret.SetString(strSecret);
- if (!fGood) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid private key");
+ if (!fGood) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid private key encoding");
CKey key = vchSecret.GetKey();
+ if (!key.IsValid()) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Private key outside allowed range");
+
CPubKey pubkey = key.GetPubKey();
CKeyID vchAddress = pubkey.GetID();
{