From: Rob Browning Date: Sat, 23 Nov 2013 19:15:45 +0000 (-0600) Subject: Fix off-by-one in MAX_PER_TREE guard in _squish(). X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=e166d6da6dbe23706b24c3a9485ea8ae7b6c7503;p=packages%2Fb%2Fbup.git Fix off-by-one in MAX_PER_TREE guard in _squish(). Previously bup would allow MAX_PER_TREE + 1 items in a tree. Change the guard to ensure that trees really are limited to MAX_PER_TREE. Thanks to Patrick Rouleau for reporting the problem. Signed-off-by: Rob Browning --- diff --git a/lib/bup/hashsplit.py b/lib/bup/hashsplit.py index 3dffbbe..345f67b 100644 --- a/lib/bup/hashsplit.py +++ b/lib/bup/hashsplit.py @@ -133,7 +133,7 @@ def _make_shalist(l): def _squish(maketree, stacks, n): i = 0 - while i MAX_PER_TREE: + while i < n or len(stacks[i]) >= MAX_PER_TREE: while len(stacks) <= i+1: stacks.append([]) if len(stacks[i]) == 1: