diff --git a/src/ripple/app/hook/Guard.h b/src/ripple/app/hook/Guard.h index 16b11b037..7e24de452 100644 --- a/src/ripple/app/hook/Guard.h +++ b/src/ripple/app/hook/Guard.h @@ -1109,8 +1109,11 @@ validateGuards( { for (auto const& [import_idx, api_name] : usage->second) { - auto const& api_signature = - hook_api::import_whitelist.find(api_name)->second; + + auto const& api_signature = + hook_api::import_whitelist.find(api_name) != hook_api::import_whitelist.end() + ? hook_api::import_whitelist.find(api_name)->second + : hook_api::import_whitelist_1.find(api_name)->second; if (!first_signature) { diff --git a/src/ripple/app/hook/impl/applyHook.cpp b/src/ripple/app/hook/impl/applyHook.cpp index dfbbb23cc..135a4af55 100644 --- a/src/ripple/app/hook/impl/applyHook.cpp +++ b/src/ripple/app/hook/impl/applyHook.cpp @@ -5521,7 +5521,7 @@ DEFINE_HOOK_FUNCTION( if (slot_into_tx > hook_api::max_slots || slot_into_meta > hook_api::max_slots) return INVALID_ARGUMENT; - size_t free_count = hookCtx.slot_free.size(); + size_t free_count = hook_api::max_slots - hookCtx.slot.size(); size_t needed_count = slot_into_tx == 0 && slot_into_meta == 0 ? 2 : slot_into_tx != 0 && slot_into_meta != 0 ? 0 : 1; diff --git a/src/ripple/app/tx/impl/Import.cpp b/src/ripple/app/tx/impl/Import.cpp index d0a16ad29..856eb5218 100644 --- a/src/ripple/app/tx/impl/Import.cpp +++ b/src/ripple/app/tx/impl/Import.cpp @@ -280,19 +280,6 @@ Import::preflight(PreflightContext const& ctx) return telWRONG_NETWORK; } -/* - // ensure the inner txn is an accountset or signerlistset - auto const tt = stpTrans->getTxnType(); - - if (tt != ttACCOUNT_SET && tt != ttSIGNER_LIST_SET && tt != ttREGULAR_KEY_SET) - { - JLOG(ctx.j.warn()) - << "Import: inner txn must be an AccountSet, SetRegularKey or SignerListSet transaction. " - << tx.getTransactionID(); - return temMALFORMED; - } -*/ - // check if the inner transaction is signed using the same keying as the outer txn { auto outer = tx.getSigningPubKey(); @@ -838,20 +825,6 @@ Import::preflight(PreflightContext const& ctx) return temMALFORMED; } - /* - * RH TODO: put this in preclaim, place sequence on an unowned object - else if (sequence < listCollection.current.sequence) - { - return ListDisposition::stale; - } - else if (sequence == listCollection.current.sequence) - return ListDisposition::same_sequence; - */ - // - // finally in preclaim check the sfImportSequence field on the account - // if it is less than the Account Sequence in the xpop then mint and - // update sfImportSequence - // Duplicate / Sanity if (!stpTrans->isFieldPresent(sfSequence) || !stpTrans->isFieldPresent(sfFee) || @@ -862,11 +835,18 @@ Import::preflight(PreflightContext const& ctx) << tx.getTransactionID(); return temMALFORMED; } + + if (stpTrans->getFieldAmount(sfFee) < beast::zero) + { + JLOG(ctx.j.warn()) + << "Import: xpop contained negative fee. " + << tx.getTransactionID(); + return temMALFORMED; + } + return preflight2(ctx); } -// RH TODO: manifest serials should be kept on chain - TER Import::preclaim(PreclaimContext const& ctx) { diff --git a/src/ripple/app/tx/impl/InvariantCheck.cpp b/src/ripple/app/tx/impl/InvariantCheck.cpp index 2202fd288..f67715989 100644 --- a/src/ripple/app/tx/impl/InvariantCheck.cpp +++ b/src/ripple/app/tx/impl/InvariantCheck.cpp @@ -196,7 +196,13 @@ XRPNotCreated::finalize( << " drops_: " << drops_ << " dropsAdded - fee.drops(): " << dropsAdded - fee.drops(); - return (drops_ == dropsAdded.drops() - fee.drops()); + int64_t drops = dropsAdded.drops() - fee.drops(); + + // catch any overflow or funny business + if (drops > dropsAdded.drops() || drops > fee.drops()) + return false; + + return drops_ == drops; }