mirror of
https://github.com/XRPLF/rippled.git
synced 2026-04-29 15:37:57 +00:00
Enforce valid range of LoanSet.InterestRate
- Addresses FIND-002 from audit. - Enforces a range of 0-100% in 1/10 bips. - Also add a couple of unit test checks.
This commit is contained in:
@@ -748,6 +748,19 @@ class Loan_test : public beast::unit_test::suite
|
||||
loanSetFee,
|
||||
ter(temINVALID));
|
||||
|
||||
// sfInterestRate: good value, bad account
|
||||
env(set(evan, broker.brokerID, principalRequest, startDate),
|
||||
sig(sfCounterpartySignature, borrower),
|
||||
interestRate(maxInterestRate),
|
||||
loanSetFee,
|
||||
ter(tefBAD_AUTH));
|
||||
// sfInterestRate: too big
|
||||
env(set(evan, broker.brokerID, principalRequest, startDate),
|
||||
sig(sfCounterpartySignature, lender),
|
||||
interestRate(maxInterestRate + 1),
|
||||
loanSetFee,
|
||||
ter(temINVALID));
|
||||
|
||||
// sfLateInterestRate: good value, bad account
|
||||
env(set(evan, broker.brokerID, principalRequest, startDate),
|
||||
sig(sfCounterpartySignature, borrower),
|
||||
|
||||
@@ -82,6 +82,8 @@ LoanSet::preflight(PreflightContext const& ctx)
|
||||
if (auto const data = tx[~sfData]; data && !data->empty() &&
|
||||
!validDataLength(tx[~sfData], maxDataPayloadLength))
|
||||
return temINVALID;
|
||||
if (!validNumericRange(tx[~sfInterestRate], maxInterestRate))
|
||||
return temINVALID;
|
||||
if (!validNumericRange(tx[~sfOverpaymentFee], maxOverpaymentFee))
|
||||
return temINVALID;
|
||||
if (!validNumericRange(tx[~sfLateInterestRate], maxLateInterestRate))
|
||||
|
||||
Reference in New Issue
Block a user