mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Clean local transaction checks. Check account field size
This commit is contained in:
@@ -765,7 +765,7 @@ void NetworkOPsImp::submitTransaction (Job&, SerializedTransaction::pointer iTra
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!isMemoOkay (*trans) || !trans->checkSign ())
|
||||
if (!passesLocalChecks (*trans) || !trans->checkSign ())
|
||||
{
|
||||
m_journal.warning << "Submitted transaction has bad signature";
|
||||
getApp().getHashRouter ().setFlag (suppress, SF_BAD);
|
||||
|
||||
@@ -313,6 +313,7 @@ std::string SerializedTransaction::getMetaSQL (Serializer rawTxn, std::uint32_t
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
bool isMemoOkay (STObject const& st)
|
||||
{
|
||||
if (!st.isFieldPresent (sfMemos))
|
||||
@@ -327,6 +328,42 @@ bool isMemoOkay (STObject const& st)
|
||||
return true;
|
||||
}
|
||||
|
||||
// Ensure all account fields are 160-bits
|
||||
bool isAccountFieldOkay (STObject const& st)
|
||||
{
|
||||
for (int i = 0; i < st.getCount(); ++i)
|
||||
{
|
||||
const STAccount* t = dynamic_cast<STAccount const*>(st.peekAtPIndex (i));
|
||||
if (t&& !t->isValueH160 ())
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool passesLocalChecks (STObject const& st, std::string& reason)
|
||||
{
|
||||
if (!isMemoOkay (st))
|
||||
{
|
||||
reason = "The memo exceeds the maximum allowed size.";
|
||||
return false;
|
||||
}
|
||||
if (!isAccountFieldOkay (st))
|
||||
{
|
||||
reason = "An account field is invalid.";
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool passesLocalChecks (STObject const& st)
|
||||
{
|
||||
std::string reason;
|
||||
return passesLocalChecks (st, reason);
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
class SerializedTransaction_test : public beast::unit_test::suite
|
||||
|
||||
@@ -153,7 +153,8 @@ private:
|
||||
mutable bool mSigBad;
|
||||
};
|
||||
|
||||
bool isMemoOkay (STObject const& st);
|
||||
bool passesLocalChecks (STObject const& st, std::string&);
|
||||
bool passesLocalChecks (STObject const& st);
|
||||
|
||||
} // ripple
|
||||
|
||||
|
||||
@@ -442,10 +442,11 @@ Json::Value RPCHandler::transactionSign (Json::Value params,
|
||||
"Exception occurred during transaction");
|
||||
}
|
||||
|
||||
if (!isMemoOkay (*stpTrans))
|
||||
std::string reason;
|
||||
if (!passesLocalChecks (*stpTrans, reason))
|
||||
{
|
||||
return RPC::make_error (rpcINVALID_PARAMS,
|
||||
"The memo exceeds the maximum allowed size.");
|
||||
reason);
|
||||
}
|
||||
|
||||
if (params.isMember ("debug_signing"))
|
||||
|
||||
@@ -33,7 +33,7 @@ Transaction::Transaction (SerializedTransaction::ref sit, bool bValidate)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!bValidate || (isMemoOkay (*mTransaction) && checkSign ()))
|
||||
if (!bValidate || (passesLocalChecks (*mTransaction) && checkSign ()))
|
||||
mStatus = NEW;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user