Skip to content

Commit

Permalink
Fix parsing of node public keys in manifest CLI:
Browse files Browse the repository at this point in the history
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 XRPLF#3317 by letting the caller specify the type of
the public key being checked.
  • Loading branch information
nbougalis authored and manojsdoshi committed Jan 15, 2021
1 parent e3ed384 commit eded9dd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/ripple/app/misc/NetworkOPs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();)
Expand Down
8 changes: 5 additions & 3 deletions src/ripple/net/impl/RPCCall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,11 @@ class RPCParser
}

static bool
validPublicKey(std::string const& strPk)
validPublicKey(
std::string const& strPk,
TokenType type = TokenType::AccountPublic)
{
if (parseBase58<PublicKey>(TokenType::AccountPublic, strPk))
if (parseBase58<PublicKey>(type, strPk))
return true;

auto pkHex = strUnHex(strPk);
Expand Down Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion src/ripple/overlay/impl/OverlayImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,6 @@ OverlayImpl::onManifests(
std::shared_ptr<protocol::TMManifests> const& m,
std::shared_ptr<PeerImp> const& from)
{
auto& hashRouter = app_.getHashRouter();
auto const n = m->list_size();
auto const& journal = from->pjournal();

Expand Down

0 comments on commit eded9dd

Please sign in to comment.