From 9786e432f8a812c5540633c196b2d5c2206fe44d Mon Sep 17 00:00:00 2001 From: Edward Hennis Date: Tue, 19 Jan 2016 15:53:12 -0500 Subject: [PATCH] ledger_request index must be positive --- src/ripple/rpc/handlers/LedgerRequest.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ripple/rpc/handlers/LedgerRequest.cpp b/src/ripple/rpc/handlers/LedgerRequest.cpp index ece6a8fecb..1537360e2f 100644 --- a/src/ripple/rpc/handlers/LedgerRequest.cpp +++ b/src/ripple/rpc/handlers/LedgerRequest.cpp @@ -52,13 +52,13 @@ Json::Value doLedgerRequest (RPC::Context& context) { auto const& jsonHash = context.params[jss::ledger_hash]; if (!jsonHash.isString() || !ledgerHash.SetHex (jsonHash.asString ())) - return RPC::invalid_field_message (jss::ledger_hash); + return RPC::invalid_field_error (jss::ledger_hash); } else { auto const& jsonIndex = context.params[jss::ledger_index]; if (!jsonIndex.isNumeric ()) - return RPC::invalid_field_message (jss::ledger_index); + return RPC::invalid_field_error (jss::ledger_index); // We need a validated ledger to get the hash from the sequence if (ledgerMaster.getValidatedLedgerAge() > @@ -70,6 +70,8 @@ Json::Value doLedgerRequest (RPC::Context& context) if (ledgerIndex >= ledger->info().seq) return RPC::make_param_error("Ledger index too large"); + if (ledgerIndex <= 0) + return RPC::make_param_error("Ledger index too small"); auto const j = context.app.journal("RPCHandler"); // Try to get the hash of the desired ledger from the validated ledger