diff --git a/src/ripple/app/paths/RippleCalc.cpp b/src/ripple/app/paths/RippleCalc.cpp index 0c2e8e71d..446521539 100644 --- a/src/ripple/app/paths/RippleCalc.cpp +++ b/src/ripple/app/paths/RippleCalc.cpp @@ -18,6 +18,7 @@ //============================================================================== #include +#include #include #include #include @@ -295,11 +296,12 @@ TER RippleCalc::rippleCalculate () } } + ++iPass; if (ShouldLog (lsDEBUG, RippleCalc)) { WriteLog (lsDEBUG, RippleCalc) << "rippleCalc: Summary:" - << " Pass: " << ++iPass + << " Pass: " << iPass << " Dry: " << iDry << " Paths: " << pathStateList_.size (); for (auto pathState: pathStateList_) @@ -374,6 +376,16 @@ TER RippleCalc::rippleCalculate () mumSource_.insert ( pathState->reverse().begin (), pathState->reverse().end ()); + if (iPass >= PAYMENT_MAX_LOOPS) + { + // This payment is taking too many passes + + WriteLog (lsERROR, RippleCalc) + << "rippleCalc: pass limit"; + + resultCode = telFAILED_PROCESSING; + } + } else if (!inputFlags.partialPaymentAllowed) { diff --git a/src/ripple/app/paths/Tuning.h b/src/ripple/app/paths/Tuning.h index d786502df..d498459ad 100644 --- a/src/ripple/app/paths/Tuning.h +++ b/src/ripple/app/paths/Tuning.h @@ -24,6 +24,7 @@ namespace ripple { int const CALC_NODE_DELIVER_MAX_LOOPS = 40; int const NODE_ADVANCE_MAX_LOOPS = 100; +int const PAYMENT_MAX_LOOPS = 1000; int const PATHFINDER_HIGH_PRIORITY = 100000; int const PATHFINDER_MAX_PATHS = 50; int const PATHFINDER_MAX_COMPLETE_PATHS = 1000;