mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-21 19:45:53 +00:00
Fix dir describer when an offer is added to a directory.
Check all amounts for orders, fees, and payments to make sure they're network legal.
This commit is contained in:
@@ -215,11 +215,12 @@ private:
|
|||||||
class STAmount : public SerializedType
|
class STAmount : public SerializedType
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static const int cMinOffset = -96, cMaxOffset = 80;
|
static const int cMinOffset = -96, cMaxOffset = 80;
|
||||||
static const uint64 cMinValue = 1000000000000000ull, cMaxValue = 9999999999999999ull;
|
static const uint64 cMinValue = 1000000000000000ull, cMaxValue = 9999999999999999ull;
|
||||||
static const uint64 cMaxNative = 9000000000000000000ull;
|
static const uint64 cMaxNative = 9000000000000000000ull;
|
||||||
static const uint64 cNotNative = 0x8000000000000000ull;
|
static const uint64 cMaxNativeN = 100000000000000000ull; // max native value on network
|
||||||
static const uint64 cPosNative = 0x4000000000000000ull;
|
static const uint64 cNotNative = 0x8000000000000000ull;
|
||||||
|
static const uint64 cPosNative = 0x4000000000000000ull;
|
||||||
|
|
||||||
static uint64 uRateOne;
|
static uint64 uRateOne;
|
||||||
|
|
||||||
@@ -311,6 +312,7 @@ public:
|
|||||||
bool isNegative() const { return mIsNegative && !isZero(); }
|
bool isNegative() const { return mIsNegative && !isZero(); }
|
||||||
bool isPositive() const { return !mIsNegative && !isZero(); }
|
bool isPositive() const { return !mIsNegative && !isZero(); }
|
||||||
bool isGEZero() const { return !mIsNegative; }
|
bool isGEZero() const { return !mIsNegative; }
|
||||||
|
bool isLegalNet() const { return !mIsNative || (mValue < cMaxNativeN); }
|
||||||
operator bool() const { return !isZero(); }
|
operator bool() const { return !isZero(); }
|
||||||
|
|
||||||
void negate() { if (!isZero()) mIsNegative = !mIsNegative; }
|
void negate() { if (!isZero()) mIsNegative = !mIsNegative; }
|
||||||
|
|||||||
@@ -367,6 +367,9 @@ TER OfferCreateTransactor::doApply()
|
|||||||
STAmount saTakerPays = mTxn.getFieldAmount(sfTakerPays);
|
STAmount saTakerPays = mTxn.getFieldAmount(sfTakerPays);
|
||||||
STAmount saTakerGets = mTxn.getFieldAmount(sfTakerGets);
|
STAmount saTakerGets = mTxn.getFieldAmount(sfTakerGets);
|
||||||
|
|
||||||
|
if (!saTakerPays.isLegalNet() || !saTakerGets.isLegalNet())
|
||||||
|
return temBAD_AMOUNT;
|
||||||
|
|
||||||
WriteLog (lsTRACE, OfferCreateTransactor) << boost::str(boost::format("OfferCreate: saTakerPays=%s saTakerGets=%s")
|
WriteLog (lsTRACE, OfferCreateTransactor) << boost::str(boost::format("OfferCreate: saTakerPays=%s saTakerGets=%s")
|
||||||
% saTakerPays.getFullText()
|
% saTakerPays.getFullText()
|
||||||
% saTakerGets.getFullText());
|
% saTakerGets.getFullText());
|
||||||
@@ -587,8 +590,7 @@ TER OfferCreateTransactor::doApply()
|
|||||||
|
|
||||||
// Add offer to owner's directory.
|
// Add offer to owner's directory.
|
||||||
terResult = lesActive.dirAdd(uOwnerNode, Ledger::getOwnerDirIndex(mTxnAccountID), uLedgerIndex,
|
terResult = lesActive.dirAdd(uOwnerNode, Ledger::getOwnerDirIndex(mTxnAccountID), uLedgerIndex,
|
||||||
BIND_TYPE(&Ledger::qualityDirDescriber, P_1, saTakerPays.getCurrency(), uPaysIssuerID,
|
BIND_TYPE(&Ledger::ownerDirDescriber, P_1, mTxnAccountID));
|
||||||
saTakerGets.getCurrency(), uGetsIssuerID, uRate));
|
|
||||||
|
|
||||||
|
|
||||||
if (tesSUCCESS == terResult)
|
if (tesSUCCESS == terResult)
|
||||||
|
|||||||
@@ -27,6 +27,9 @@ TER PaymentTransactor::doApply()
|
|||||||
% saMaxAmount.getFullText()
|
% saMaxAmount.getFullText()
|
||||||
% saDstAmount.getFullText());
|
% saDstAmount.getFullText());
|
||||||
|
|
||||||
|
if (!saDstAmount.isLegalNet() || !saMaxAmount.isLegalNet())
|
||||||
|
return temBAD_AMOUNT;
|
||||||
|
|
||||||
if (uTxFlags & tfPaymentMask)
|
if (uTxFlags & tfPaymentMask)
|
||||||
{
|
{
|
||||||
WriteLog (lsINFO, PaymentTransactor) << "Payment: Malformed transaction: Invalid flags set.";
|
WriteLog (lsINFO, PaymentTransactor) << "Payment: Malformed transaction: Invalid flags set.";
|
||||||
|
|||||||
@@ -48,6 +48,8 @@ uint64 Transactor::calculateBaseFee()
|
|||||||
TER Transactor::payFee()
|
TER Transactor::payFee()
|
||||||
{
|
{
|
||||||
STAmount saPaid = mTxn.getTransactionFee();
|
STAmount saPaid = mTxn.getTransactionFee();
|
||||||
|
if (!saPaid.isLegalNet())
|
||||||
|
return temBAD_AMOUNT;
|
||||||
|
|
||||||
// Only check fee is sufficient when the ledger is open.
|
// Only check fee is sufficient when the ledger is open.
|
||||||
if (isSetBit(mParams, tapOPEN_LEDGER) && saPaid < mFeeDue)
|
if (isSetBit(mParams, tapOPEN_LEDGER) && saPaid < mFeeDue)
|
||||||
|
|||||||
@@ -16,6 +16,9 @@ TER TrustSetTransactor::doApply()
|
|||||||
uint32 uQualityIn = bQualityIn ? mTxn.getFieldU32(sfQualityIn) : 0;
|
uint32 uQualityIn = bQualityIn ? mTxn.getFieldU32(sfQualityIn) : 0;
|
||||||
uint32 uQualityOut = bQualityOut ? mTxn.getFieldU32(sfQualityOut) : 0;
|
uint32 uQualityOut = bQualityOut ? mTxn.getFieldU32(sfQualityOut) : 0;
|
||||||
|
|
||||||
|
if (!saLimitAmount.isLegalNet())
|
||||||
|
return temBAD_AMOUNT;
|
||||||
|
|
||||||
if (bQualityIn && QUALITY_ONE == uQualityIn)
|
if (bQualityIn && QUALITY_ONE == uQualityIn)
|
||||||
uQualityIn = 0;
|
uQualityIn = 0;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user