From 5180c39f464ec0d3b616f0b0bcea37a33e3d0c6f Mon Sep 17 00:00:00 2001 From: Alphonse Noni Mousse <39067955+a-noni-mousse@users.noreply.github.com> Date: Sun, 7 May 2023 20:33:29 +0000 Subject: [PATCH 1/3] Improve checking of the path lengths during Payments --- src/ripple/app/tx/impl/Payment.cpp | 33 +++++++++--------------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/src/ripple/app/tx/impl/Payment.cpp b/src/ripple/app/tx/impl/Payment.cpp index ccb0f1935a9..996c7d69c58 100644 --- a/src/ripple/app/tx/impl/Payment.cpp +++ b/src/ripple/app/tx/impl/Payment.cpp @@ -270,27 +270,17 @@ Payment::preclaim(PreclaimContext const& ctx) return tecDST_TAG_NEEDED; } - if (paths || sendMax || !saDstAmount.native()) + // Payment with at least one intermediate step and uses transitive balances. + if ((paths || sendMax || !saDstAmount.native()) && ctx.view.open()) { - // Ripple payment with at least one intermediate step and uses - // transitive balances. - - // Copy paths into an editable class. - STPathSet const spsPaths = ctx.tx.getFieldPathSet(sfPaths); - - auto pathTooBig = spsPaths.size() > MaxPathSize; + STPathSet const& paths = ctx.tx.getFieldPathSet(sfPaths); - if (!pathTooBig) - for (auto const& path : spsPaths) - if (path.size() > MaxPathLength) - { - pathTooBig = true; - break; - } - - if (ctx.view.open() && pathTooBig) + if (paths.size() > MaxPathSize || + std::any_of(paths.begin(), paths.end(), [](STPath const& path) { + return path.size() > MaxPathSize; + })) { - return telBAD_PATH_COUNT; // Too many paths for proposed ledger. + return telBAD_PATH_COUNT; } } @@ -383,10 +373,7 @@ Payment::doApply() return tecNO_PERMISSION; } } - - // Copy paths into an editable class. - STPathSet spsPaths = ctx_.tx.getFieldPathSet(sfPaths); - + path::RippleCalc::Input rcInput; rcInput.partialPaymentAllowed = partialPaymentAllowed; rcInput.defaultPathsAllowed = defaultPathsAllowed; @@ -404,7 +391,7 @@ Payment::doApply() saDstAmount, uDstAccountID, account_, - spsPaths, + ctx_.tx.getFieldPathSet(sfPaths), ctx_.app.logs(), &rcInput); // VFALCO NOTE We might not need to apply, depending From 8194570538c6fc395c023e19a14f63c3f237cddc Mon Sep 17 00:00:00 2001 From: Alphonse Noni Mousse <39067955+a-noni-mousse@users.noreply.github.com> Date: Thu, 11 May 2023 18:17:40 +0000 Subject: [PATCH 2/3] Fix the copy-paste mistake --- src/ripple/app/tx/impl/Payment.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ripple/app/tx/impl/Payment.cpp b/src/ripple/app/tx/impl/Payment.cpp index 996c7d69c58..43c9b063d2e 100644 --- a/src/ripple/app/tx/impl/Payment.cpp +++ b/src/ripple/app/tx/impl/Payment.cpp @@ -277,7 +277,7 @@ Payment::preclaim(PreclaimContext const& ctx) if (paths.size() > MaxPathSize || std::any_of(paths.begin(), paths.end(), [](STPath const& path) { - return path.size() > MaxPathSize; + return path.size() > MaxPathLength; })) { return telBAD_PATH_COUNT; From 3951044f555ce12336e0fb97139d67d698b90d04 Mon Sep 17 00:00:00 2001 From: Alphonse Noni Mousse <39067955+a-noni-mousse@users.noreply.github.com> Date: Sun, 6 Aug 2023 15:14:14 +0000 Subject: [PATCH 3/3] Update Payment.cpp --- src/ripple/app/tx/impl/Payment.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ripple/app/tx/impl/Payment.cpp b/src/ripple/app/tx/impl/Payment.cpp index eb93766d511..f5d831bcc82 100644 --- a/src/ripple/app/tx/impl/Payment.cpp +++ b/src/ripple/app/tx/impl/Payment.cpp @@ -373,7 +373,7 @@ Payment::doApply() return tecNO_PERMISSION; } } - + path::RippleCalc::Input rcInput; rcInput.partialPaymentAllowed = partialPaymentAllowed; rcInput.defaultPathsAllowed = defaultPathsAllowed;