From 012bbcfe3638a75d7244749f5153a1a900b20611 Mon Sep 17 00:00:00 2001 From: Nik Bougalis Date: Wed, 13 Jan 2021 03:09:39 -0800 Subject: [PATCH] Fix parsing of node public keys in `manifest` CLI: The existing code attempts to validate the provided node public key using a function that assumes that the encoded public key is for an account. This causes the parsing to fail. This commit fixes #3317 by letting the caller specify the type of the public key being checked. --- src/ripple/app/misc/NetworkOPs.cpp | 1 + src/ripple/net/impl/RPCCall.cpp | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/ripple/app/misc/NetworkOPs.cpp b/src/ripple/app/misc/NetworkOPs.cpp index 84ba65dc8..8b883d454 100644 --- a/src/ripple/app/misc/NetworkOPs.cpp +++ b/src/ripple/app/misc/NetworkOPs.cpp @@ -1915,6 +1915,7 @@ NetworkOPsImp::pubManifest(Manifest const& mo) jvObj[jss::master_signature] = strHex(mo.getMasterSignature()); if (!mo.domain.empty()) jvObj[jss::domain] = mo.domain; + jvObj[jss::manifest] = strHex(mo.serialized); for (auto i = mStreamMaps[sManifests].begin(); i != mStreamMaps[sManifests].end();) diff --git a/src/ripple/net/impl/RPCCall.cpp b/src/ripple/net/impl/RPCCall.cpp index 9a79515a2..b3d8f4e47 100644 --- a/src/ripple/net/impl/RPCCall.cpp +++ b/src/ripple/net/impl/RPCCall.cpp @@ -151,9 +151,11 @@ private: } static bool - validPublicKey(std::string const& strPk) + validPublicKey( + std::string const& strPk, + TokenType type = TokenType::AccountPublic) { - if (parseBase58(TokenType::AccountPublic, strPk)) + if (parseBase58(type, strPk)) return true; auto pkHex = strUnHex(strPk); @@ -235,7 +237,7 @@ private: Json::Value jvRequest(Json::objectValue); std::string const strPk = jvParams[0u].asString(); - if (!validPublicKey(strPk)) + if (!validPublicKey(strPk, TokenType::NodePublic)) return rpcError(rpcPUBLIC_MALFORMED); jvRequest[jss::public_key] = strPk;