mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-20 11:05:54 +00:00
Compare commits
1 Commits
a1q123456/
...
develop
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6ff495fd9b |
@@ -1103,7 +1103,7 @@ class LedgerEntry_test : public beast::unit_test::suite
|
|||||||
checkErrorValue(
|
checkErrorValue(
|
||||||
jrr[jss::result],
|
jrr[jss::result],
|
||||||
"malformedAuthorizedCredentials",
|
"malformedAuthorizedCredentials",
|
||||||
"Invalid field 'authorized_credentials', not array.");
|
"Invalid field 'authorized_credentials', array empty.");
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -1144,7 +1144,7 @@ class LedgerEntry_test : public beast::unit_test::suite
|
|||||||
checkErrorValue(
|
checkErrorValue(
|
||||||
jrr[jss::result],
|
jrr[jss::result],
|
||||||
"malformedAuthorizedCredentials",
|
"malformedAuthorizedCredentials",
|
||||||
"Invalid field 'authorized_credentials', not array.");
|
"Invalid field 'authorized_credentials', array too long.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,8 +16,6 @@
|
|||||||
#include <xrpl/protocol/STXChainBridge.h>
|
#include <xrpl/protocol/STXChainBridge.h>
|
||||||
#include <xrpl/protocol/jss.h>
|
#include <xrpl/protocol/jss.h>
|
||||||
|
|
||||||
#include <functional>
|
|
||||||
|
|
||||||
namespace ripple {
|
namespace ripple {
|
||||||
|
|
||||||
static Expected<uint256, Json::Value>
|
static Expected<uint256, Json::Value>
|
||||||
@@ -178,18 +176,41 @@ static Expected<STArray, Json::Value>
|
|||||||
parseAuthorizeCredentials(Json::Value const& jv)
|
parseAuthorizeCredentials(Json::Value const& jv)
|
||||||
{
|
{
|
||||||
if (!jv.isArray())
|
if (!jv.isArray())
|
||||||
|
{
|
||||||
return LedgerEntryHelpers::invalidFieldError(
|
return LedgerEntryHelpers::invalidFieldError(
|
||||||
"malformedAuthorizedCredentials",
|
"malformedAuthorizedCredentials",
|
||||||
jss::authorized_credentials,
|
jss::authorized_credentials,
|
||||||
"array");
|
"array");
|
||||||
STArray arr(sfAuthorizeCredentials, jv.size());
|
}
|
||||||
|
|
||||||
|
std::uint32_t const n = jv.size();
|
||||||
|
if (n > maxCredentialsArraySize)
|
||||||
|
{
|
||||||
|
return Unexpected(LedgerEntryHelpers::malformedError(
|
||||||
|
"malformedAuthorizedCredentials",
|
||||||
|
"Invalid field '" + std::string(jss::authorized_credentials) +
|
||||||
|
"', array too long."));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (n == 0)
|
||||||
|
{
|
||||||
|
return Unexpected(LedgerEntryHelpers::malformedError(
|
||||||
|
"malformedAuthorizedCredentials",
|
||||||
|
"Invalid field '" + std::string(jss::authorized_credentials) +
|
||||||
|
"', array empty."));
|
||||||
|
}
|
||||||
|
|
||||||
|
STArray arr(sfAuthorizeCredentials, n);
|
||||||
for (auto const& jo : jv)
|
for (auto const& jo : jv)
|
||||||
{
|
{
|
||||||
if (!jo.isObject())
|
if (!jo.isObject())
|
||||||
|
{
|
||||||
return LedgerEntryHelpers::invalidFieldError(
|
return LedgerEntryHelpers::invalidFieldError(
|
||||||
"malformedAuthorizedCredentials",
|
"malformedAuthorizedCredentials",
|
||||||
jss::authorized_credentials,
|
jss::authorized_credentials,
|
||||||
"array");
|
"array");
|
||||||
|
}
|
||||||
|
|
||||||
if (auto const value = LedgerEntryHelpers::hasRequired(
|
if (auto const value = LedgerEntryHelpers::hasRequired(
|
||||||
jo,
|
jo,
|
||||||
{jss::issuer, jss::credential_type},
|
{jss::issuer, jss::credential_type},
|
||||||
@@ -260,13 +281,6 @@ parseDepositPreauth(Json::Value const& dp, Json::StaticString const fieldName)
|
|||||||
auto const arr = parseAuthorizeCredentials(ac);
|
auto const arr = parseAuthorizeCredentials(ac);
|
||||||
if (!arr.has_value())
|
if (!arr.has_value())
|
||||||
return Unexpected(arr.error());
|
return Unexpected(arr.error());
|
||||||
if (arr->empty() || (arr->size() > maxCredentialsArraySize))
|
|
||||||
{
|
|
||||||
return LedgerEntryHelpers::invalidFieldError(
|
|
||||||
"malformedAuthorizedCredentials",
|
|
||||||
jss::authorized_credentials,
|
|
||||||
"array");
|
|
||||||
}
|
|
||||||
|
|
||||||
auto const& sorted = credentials::makeSorted(arr.value());
|
auto const& sorted = credentials::makeSorted(arr.value());
|
||||||
if (sorted.empty())
|
if (sorted.empty())
|
||||||
|
|||||||
Reference in New Issue
Block a user