From eded9ddf3658199f64c9901c1bd866be8391dbf9 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 +++++--- src/ripple/overlay/impl/OverlayImpl.cpp | 1 - 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/ripple/app/misc/NetworkOPs.cpp b/src/ripple/app/misc/NetworkOPs.cpp index c4bb8e41217..bc8bfda8c51 100644 --- a/src/ripple/app/misc/NetworkOPs.cpp +++ b/src/ripple/app/misc/NetworkOPs.cpp @@ -1924,6 +1924,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 9a79515a252..b3d8f4e4746 100644 --- a/src/ripple/net/impl/RPCCall.cpp +++ b/src/ripple/net/impl/RPCCall.cpp @@ -151,9 +151,11 @@ class RPCParser } 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 @@ class RPCParser 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; diff --git a/src/ripple/overlay/impl/OverlayImpl.cpp b/src/ripple/overlay/impl/OverlayImpl.cpp index 3795080e4d8..409d687cd50 100644 --- a/src/ripple/overlay/impl/OverlayImpl.cpp +++ b/src/ripple/overlay/impl/OverlayImpl.cpp @@ -658,7 +658,6 @@ OverlayImpl::onManifests( std::shared_ptr const& m, std::shared_ptr const& from) { - auto& hashRouter = app_.getHashRouter(); auto const n = m->list_size(); auto const& journal = from->pjournal();