mirror of
https://github.com/XRPLF/rippled.git
synced 2026-06-02 08:17:13 +00:00
fix: account_tx limit parameter validation for malformed values (#5891)
This change fixes the `account_tx` RPC method to properly validate malformed limit parameter values. Previously, invalid values like `0`, `1.2`, `"10"`, `true`, `false`, `-1`, `[]`, `{}`, etc. were either accepted without errors or caused internal errors. Now all malformed values correctly return the `invalidParams` error.
Co-authored-by: Bart Thomee <11445373+bthomee@users.noreply.github.com>
This commit is contained in:
@@ -1633,6 +1633,20 @@ public:
|
||||
"Invalid field 'limit', not unsigned integer.");
|
||||
}
|
||||
|
||||
{
|
||||
Json::Value jvParams;
|
||||
jvParams[jss::ledger_index] = "validated";
|
||||
jvParams[jss::taker] = env.master.human();
|
||||
jvParams[jss::limit] = 0; // must be > 0
|
||||
jvParams[jss::taker_pays][jss::currency] = "XRP";
|
||||
jvParams[jss::taker_gets][jss::currency] = "USD";
|
||||
jvParams[jss::taker_gets][jss::issuer] = gw.human();
|
||||
auto const jrr = env.rpc(
|
||||
"json", "book_offers", to_string(jvParams))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jrr[jss::error_message] == "Invalid field 'limit'.");
|
||||
}
|
||||
|
||||
{
|
||||
Json::Value jvParams;
|
||||
jvParams[jss::ledger_index] = "validated";
|
||||
@@ -1710,11 +1724,6 @@ public:
|
||||
BEAST_EXPECT(jrr[jss::offers].size() == (asAdmin ? 1u : 0u));
|
||||
// NOTE - a marker field is not returned for this method
|
||||
|
||||
jvParams[jss::limit] = 0u;
|
||||
jrr = env.rpc("json", "book_offers", to_string(jvParams))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::offers].isArray());
|
||||
BEAST_EXPECT(jrr[jss::offers].size() == 0u);
|
||||
|
||||
jvParams[jss::limit] = RPC::Tuning::bookOffers.rmax + 1;
|
||||
jrr = env.rpc("json", "book_offers", to_string(jvParams))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::offers].isArray());
|
||||
|
||||
Reference in New Issue
Block a user