diff -u -r '--exclude=.git' 1.9.1/src/allmydata/mutable/common.py 1.9.1-debugging-ticket1669/src/allmydata/mutable/common.py --- 1.9.1/src/allmydata/mutable/common.py 2012-01-12 12:05:20.000000000 -0400 +++ 1.9.1-debugging-ticket1669/src/allmydata/mutable/common.py 2012-06-18 14:07:48.199757241 -0300 @@ -1,5 +1,5 @@ -from allmydata.util import idlib +from allmydata.util import hashutil, idlib from allmydata.util.spans import DataSpans MODE_CHECK = "MODE_CHECK" # query all peers @@ -53,6 +53,30 @@ self.shnum, self.reason) +def check_is_verinfo(x): + if not isinstance(x, tuple): + raise TypeError("This isn't a verinfo because its type is %s instead of tuple. %r" % (type(x), x,)) + if len(x) != 9: + raise TypeError("This isn't a verinfo because its length is %s instead of 9. %r :: %s" % (len(x), x, type(x),)) + if not isinstance(x[0], (int, long)): + raise TypeError("This isn't a verinfo because the type of its 0 element is %s instead of int/long. %r :: %s" % (type(x[0]), x, type(x),)) + if not hashutil.is_hash(x[1]): + raise TypeError("This isn't a verinfo because its 1 element (%r :: %s) is not a hash. %r :: %s" % (x[1], type(x[1]), x, type(x),)) + if not hashutil.is_hash(x[2]): + raise TypeError("This isn't a verinfo because its 2 element (%r :: %s) is not a hash. %r :: %s" % (x[2], type(x[2]), x, type(x),)) + if not isinstance(x[3], (int, long)): + raise TypeError("This isn't a verinfo because the type of its 3 element is %s instead of int/long. %r :: %s" % (type(x[3]), x, type(x),)) + if not isinstance(x[4], (int, long)): + raise TypeError("This isn't a verinfo because the type of its 4 element is %s instead of int/long. %r :: %s" % (type(x[4]), x, type(x),)) + if not isinstance(x[5], (int, long)): + raise TypeError("This isn't a verinfo because the type of its 5 element is %s instead of int/long. %r :: %s" % (type(x[5]), x, type(x),)) + if not isinstance(x[6], (int, long)): + raise TypeError("This isn't a verinfo because the type of its 6 element is %s instead of int/long. %r :: %s" % (type(x[6]), x, type(x),)) + if not isinstance(x[7], str): + raise TypeError("This isn't a verinfo because the type of its 7 element is %s instead of str. %r :: %s" % (type(x[7]), x, type(x),)) + if not isinstance(x[8], tuple): + raise TypeError("This isn't a verinfo because the type of its 8 element is %s instead of tuple. %r :: %s" % (type(x[7]), x, type(x),)) + class UnknownVersionError(Exception): """The share we received was of a version we don't recognize.""" diff -u -r '--exclude=.git' 1.9.1/src/allmydata/mutable/publish.py 1.9.1-debugging-ticket1669/src/allmydata/mutable/publish.py --- 1.9.1/src/allmydata/mutable/publish.py 2012-01-12 12:05:20.000000000 -0400 +++ 1.9.1-debugging-ticket1669/src/allmydata/mutable/publish.py 2012-06-18 14:13:10.108501792 -0300 @@ -16,7 +16,7 @@ from foolscap.api import eventually, fireEventually from allmydata.mutable.common import MODE_WRITE, MODE_CHECK, \ - UncoordinatedWriteError, NotEnoughServersError + UncoordinatedWriteError, NotEnoughServersError, check_is_verinfo from allmydata.mutable.servermap import ServerMap from allmydata.mutable.layout import get_version_from_checkstring,\ unpack_mdmf_checkstring, \ @@ -883,6 +883,7 @@ def _record_verinfo(self): self.versioninfo = self.writers.values()[0].get_verinfo() + check_is_verinfo(self.versioninfo) def _connection_problem(self, f, writer): diff -u -r '--exclude=.git' 1.9.1/src/allmydata/mutable/servermap.py 1.9.1-debugging-ticket1669/src/allmydata/mutable/servermap.py --- 1.9.1/src/allmydata/mutable/servermap.py 2012-01-12 12:05:20.000000000 -0400 +++ 1.9.1-debugging-ticket1669/src/allmydata/mutable/servermap.py 2012-06-18 17:14:45.901013590 -0300 @@ -13,7 +13,7 @@ from pycryptopp.publickey import rsa from allmydata.mutable.common import MODE_CHECK, MODE_ANYTHING, MODE_WRITE, MODE_READ, \ - CorruptShareError + CorruptShareError, check_is_verinfo from allmydata.mutable.layout import SIGNED_PREFIX_LENGTH, MDMFSlotReadProxy class UpdateStatus: @@ -631,6 +631,7 @@ to occur when the file is downloaded, or when the file is updated. """ + check_is_verinfo(verinfo) if verinfo: self._node._add_to_cache(verinfo, shnum, 0, data) @@ -695,6 +696,7 @@ # bytes of the share on the storage server, so we # shouldn't need to fetch anything at this step. d2 = reader.get_verinfo() + check_is_verinfo(d2) d2.addErrback(lambda error, shnum=shnum, peerid=peerid, data=data: self._got_corrupt_share(error, shnum, peerid, data, lp)) # - Next, we need the signature. For an SDMF share, it is @@ -730,6 +732,8 @@ # make the two routines share the value without # introducing more roundtrips? ds.append(reader.get_verinfo()) + v = ds[-1] + check_is_verinfo(v) ds.append(reader.get_blockhashes()) ds.append(reader.get_block_and_salt(self.start_segment)) ds.append(reader.get_block_and_salt(self.end_segment)) @@ -809,6 +813,7 @@ return None _, verinfo, signature, __, ___ = results + check_is_verinfo(verinfo) (seqnum, root_hash, saltish, @@ -831,6 +836,7 @@ n, prefix, offsets_tuple) + check_is_verinfo(verinfo) # This tuple uniquely identifies a share on the grid; we use it # to keep track of the ones that we've already seen. @@ -880,6 +886,7 @@ """ assert len(results) == 4 verinfo, blockhashes, start, end = results + check_is_verinfo(verinfo) (seqnum, root_hash, saltish, @@ -902,6 +909,7 @@ n, prefix, offsets_tuple) + check_is_verinfo(verinfo) update_data = (blockhashes, start, end) self._servermap.set_update_data_for_share_and_verinfo(share, diff -u -r '--exclude=.git' 1.9.1/src/allmydata/util/hashutil.py 1.9.1-debugging-ticket1669/src/allmydata/util/hashutil.py --- 1.9.1/src/allmydata/util/hashutil.py 2012-01-12 12:05:20.000000000 -0400 +++ 1.9.1-debugging-ticket1669/src/allmydata/util/hashutil.py 2012-06-18 14:00:16.454852387 -0300 @@ -209,3 +209,7 @@ BACKUPDB_DIRHASH_TAG = "allmydata_backupdb_dirhash_v1" def backupdb_dirhash(contents): return tagged_hash(BACKUPDB_DIRHASH_TAG, contents) + +def is_hash(x): + return isinstance(x, str) and len(x) == CRYPTO_VAL_SIZE +