Reject invalid MessageKey in SetAccount handler (RIPD-308, RIPD-990)

This commit is contained in:
Nik Bougalis
2016-05-01 17:29:04 -07:00
committed by Howard Hinnant
parent 2ae68923cc
commit 4d19b8be07
2 changed files with 8 additions and 6 deletions

View File

@@ -23,6 +23,7 @@
#include <ripple/core/Config.h>
#include <ripple/protocol/Feature.h>
#include <ripple/protocol/Indexes.h>
#include <ripple/protocol/PublicKey.h>
#include <ripple/protocol/Quality.h>
#include <ripple/protocol/st.h>
#include <ripple/ledger/View.h>
@@ -123,15 +124,17 @@ SetAccount::preflight (PreflightContext const& ctx)
}
}
auto const messageKey = tx[~sfMessageKey];
if (messageKey && messageKey->size() > PUBLIC_BYTES_MAX)
if (auto const mk = tx[~sfMessageKey])
{
JLOG(j.trace()) << "message key too long";
return telBAD_PUBLIC_KEY;
if (mk->size() && ! publicKeyType ({mk->data(), mk->size()}))
{
JLOG(j.trace()) << "Invalid message key specified.";
return telBAD_PUBLIC_KEY;
}
}
auto const domain = tx[~sfDomain];
if (domain&& domain->size() > DOMAIN_BYTES_MAX)
if (domain && domain->size() > DOMAIN_BYTES_MAX)
{
JLOG(j.trace()) << "domain too long";
return telBAD_DOMAIN;

View File

@@ -33,7 +33,6 @@ class SetAccount
: public Transactor
{
static std::size_t const DOMAIN_BYTES_MAX = 256;
static std::size_t const PUBLIC_BYTES_MAX = 33;
public:
SetAccount (ApplyContext& ctx)