mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Permit memos up to 1Kb.
* Overlong memos are basically treated like invalid signatures. * Ability to clear message key.
This commit is contained in:
committed by
Vinnie Falco
parent
ae649ec917
commit
370bfb7a22
@@ -733,7 +733,7 @@ void NetworkOPsImp::submitTransaction (Job&, SerializedTransaction::pointer iTra
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!trans->checkSign ())
|
||||
if (!trans->isMemoOkay () || !trans->checkSign ())
|
||||
{
|
||||
m_journal.warning << "Submitted transaction has bad signature";
|
||||
getApp().getHashRouter ().setFlag (suppress, SF_BAD);
|
||||
|
||||
@@ -307,6 +307,19 @@ std::string SerializedTransaction::getMetaSQL (Serializer rawTxn, uint32 inLedge
|
||||
% getSequence () % inLedger % status % rTxn % escapedMetaData);
|
||||
}
|
||||
|
||||
bool SerializedTransaction::isMemoOkay ()
|
||||
{
|
||||
bool ret = true;
|
||||
if (isFieldPresent (sfMemos))
|
||||
{
|
||||
Serializer s (2048); // Try to avoid allocate/copy/free's
|
||||
getFieldArray (sfMemos).add (s);
|
||||
if (s.getDataLength () > 1024)
|
||||
ret = false;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
class SerializedTransactionTests : public UnitTest
|
||||
|
||||
@@ -124,6 +124,8 @@ public:
|
||||
mSigBad = true;
|
||||
}
|
||||
|
||||
bool isMemoOkay ();
|
||||
|
||||
// SQL Functions
|
||||
static std::string getSQLValueHeader ();
|
||||
static std::string getSQLInsertHeader ();
|
||||
|
||||
@@ -165,7 +165,6 @@ static void autofill_fee (Json::Value& request,
|
||||
Json::Value RPCHandler::transactionSign (Json::Value params,
|
||||
bool bSubmit, bool bFailHard, Application::ScopedLockType& mlh)
|
||||
{
|
||||
mlh.unlock();
|
||||
Json::Value jvResult;
|
||||
|
||||
WriteLog (lsDEBUG, RPCHandler) << boost::str (boost::format ("transactionSign: %s") % params);
|
||||
@@ -431,6 +430,14 @@ Json::Value RPCHandler::transactionSign (Json::Value params,
|
||||
return jvResult;
|
||||
}
|
||||
|
||||
if (!stpTrans->isMemoOkay ())
|
||||
{
|
||||
jvResult["error"] = "invalidTransaction";
|
||||
jvResult["error_exception"] = "overlong memos";
|
||||
|
||||
return jvResult;
|
||||
}
|
||||
|
||||
if (params.isMember ("debug_signing"))
|
||||
{
|
||||
jvResult["tx_unsigned"] = strHex (stpTrans->getSerializer ().peekData ());
|
||||
@@ -1975,6 +1982,8 @@ Json::Value RPCHandler::doRipplePathFind (Json::Value params, Resource::Charge&
|
||||
// }
|
||||
Json::Value RPCHandler::doSign (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
|
||||
{
|
||||
masterLockHolder.unlock ();
|
||||
|
||||
loadType = Resource::feeHighBurdenRPC;
|
||||
bool bFailHard = params.isMember ("fail_hard") && params["fail_hard"].asBool ();
|
||||
return transactionSign (params, false, bFailHard, masterLockHolder);
|
||||
@@ -1986,6 +1995,8 @@ Json::Value RPCHandler::doSign (Json::Value params, Resource::Charge& loadType,
|
||||
// }
|
||||
Json::Value RPCHandler::doSubmit (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder)
|
||||
{
|
||||
masterLockHolder.unlock ();
|
||||
|
||||
loadType = Resource::feeMediumBurdenRPC;
|
||||
|
||||
if (!params.isMember ("tx_blob"))
|
||||
@@ -2048,7 +2059,6 @@ Json::Value RPCHandler::doSubmit (Json::Value params, Resource::Charge& loadType
|
||||
return jvResult;
|
||||
}
|
||||
|
||||
masterLockHolder.unlock ();
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
@@ -226,6 +226,12 @@ TER AccountSetTransactor::doApply ()
|
||||
{
|
||||
Blob vucPublic = mTxn.getFieldVL (sfMessageKey);
|
||||
|
||||
if (vucPublic.empty ())
|
||||
{
|
||||
WriteLog (lsDEBUG, AccountSetTransactor) << "AccountSet: set message key";
|
||||
|
||||
mTxnAccount->makeFieldAbsent (sfMessageKey);
|
||||
}
|
||||
if (vucPublic.size () > PUBLIC_BYTES_MAX)
|
||||
{
|
||||
WriteLog (lsINFO, AccountSetTransactor) << "AccountSet: message key too long";
|
||||
@@ -234,7 +240,7 @@ TER AccountSetTransactor::doApply ()
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteLog (lsINFO, AccountSetTransactor) << "AccountSet: set message key";
|
||||
WriteLog (lsDEBUG, AccountSetTransactor) << "AccountSet: set message key";
|
||||
|
||||
mTxnAccount->setFieldVL (sfMessageKey, vucPublic);
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ Transaction::Transaction (SerializedTransaction::ref sit, bool bValidate)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!bValidate || checkSign ())
|
||||
if (!bValidate || (mTransaction->isMemoOkay () && checkSign ()))
|
||||
mStatus = NEW;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user