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 20, 2021
1 parent a582260 commit a143818
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 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 @@ -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();)
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

0 comments on commit a143818

Please sign in to comment.