From: Zooko O'Whielacronx <zooko@zooko.com>
Date: Thu, 16 Oct 2008 19:48:48 +0000 (-0700)
Subject: repairer: fix flaw in testutil.flip_one_bit() that Brian pointed out
X-Git-Url: https://git.rkrishnan.org/specifications/components/statistics?a=commitdiff_plain;h=57d9f6beb61fdd01c765a26a7e8aaf4e2caa6919;p=tahoe-lafs%2Ftahoe-lafs.git

repairer: fix flaw in testutil.flip_one_bit() that Brian pointed out
---

diff --git a/src/allmydata/util/testutil.py b/src/allmydata/util/testutil.py
index 27e4f069..84911306 100644
--- a/src/allmydata/util/testutil.py
+++ b/src/allmydata/util/testutil.py
@@ -19,7 +19,7 @@ def flip_one_bit(s, offset=0, size=None):
     """ flip one random bit of the string s, in a byte greater than or equal to offset and less
     than offset+size. """
     if size is None:
-        size=len(s)
+        size=len(s)-offset
     i = randrange(offset, offset+size)
     result = s[:i] + chr(ord(s[i])^(0x01<<randrange(0, 8))) + s[i+1:]
     assert result != s, "Internal error -- flip_one_bit() produced the same string as its input: %s == %s" % (result, s)