Limit passes in the payment engine to prevent endless looping:

This adds a limit of 1,000 passes to the payment engine. It protects against
possible cases where the execution of a pass fails to exhaust the liquidity
that made the pass possible or cases where two passes alternate providing
liquidity for each other.
This commit is contained in:
JoelKatz
2015-03-03 14:01:38 -08:00
committed by Tom Ritchford
parent cbeae85731
commit eaa1f47f00
2 changed files with 12 additions and 0 deletions

View File

@@ -18,6 +18,7 @@
//==============================================================================
#include <BeastConfig.h>
#include <ripple/app/paths/Tuning.h>
#include <ripple/app/paths/RippleCalc.h>
#include <ripple/app/paths/cursor/PathCursor.h>
#include <ripple/basics/Log.h>
@@ -374,6 +375,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)
{

View File

@@ -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;