From 9c390f6da4a53b36e398006802e9d853f2562ae2 Mon Sep 17 00:00:00 2001 From: David Schwartz Date: Fri, 4 Jul 2014 00:47:40 +0000 Subject: [PATCH] Impose a local limit on path lengths (RIPD-350) --- src/ripple/module/app/transactors/Payment.cpp | 9 +++++++-- src/ripple/module/app/transactors/Payment.h | 3 +++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/ripple/module/app/transactors/Payment.cpp b/src/ripple/module/app/transactors/Payment.cpp index 21809d88b9..aeabcdec25 100644 --- a/src/ripple/module/app/transactors/Payment.cpp +++ b/src/ripple/module/app/transactors/Payment.cpp @@ -240,9 +240,14 @@ TER Payment::doApply () try { bool const openLedger = (mParams & tapOPEN_LEDGER); - bool const tooManyPaths = spsPaths.size () > MaxPathSize; - terResult = openLedger && tooManyPaths + bool pathTooBig = spsPaths.size () > MaxPathSize; + + for (auto const& path : spsPaths) + if (path.size () > MaxPathLength) + pathTooBig = true; + + terResult = openLedger && pathTooBig ? telBAD_PATH_COUNT // Too many paths for proposed ledger. : path::rippleCalculate ( mEngine->view (), diff --git a/src/ripple/module/app/transactors/Payment.h b/src/ripple/module/app/transactors/Payment.h index 9649caf496..064273226d 100644 --- a/src/ripple/module/app/transactors/Payment.h +++ b/src/ripple/module/app/transactors/Payment.h @@ -28,6 +28,9 @@ class Payment /* The largest number of paths we allow */ static std::size_t const MaxPathSize = 6; + /* The longest path we allow */ + static std::size_t const MaxPathLength = 8; + public: Payment ( SerializedTransaction const& txn,