From: Zooko O'Whielacronx Date: Tue, 10 Feb 2009 06:46:05 +0000 (-0700) Subject: immutable: defensive programming: assert that the encrypted readable gave you no... X-Git-Tag: allmydata-tahoe-1.3.0~51 X-Git-Url: https://git.rkrishnan.org/pf/content/cyclelanguage?a=commitdiff_plain;h=c59940852b94ba458cd5e3565e2679dc6af5d21f;p=tahoe-lafs%2Ftahoe-lafs.git immutable: defensive programming: assert that the encrypted readable gave you no more than the number of bytes you asked for (There is a bug in the current DownUpConnector which can cause it to give more bytes than you asked for on one request, and then less on the next, effectively shifting some of the bytes to an earlier request, but I think this bug never gets triggered in practice.) --- diff --git a/src/allmydata/immutable/encode.py b/src/allmydata/immutable/encode.py index 3ef9f3ae..e13ea7cd 100644 --- a/src/allmydata/immutable/encode.py +++ b/src/allmydata/immutable/encode.py @@ -389,6 +389,9 @@ class Encoder(object): self._crypttext_hasher.update(encrypted_piece) encrypted_pieces.append(encrypted_piece) + precondition(length <= input_chunk_size, + "length=%d > input_chunk_size=%d" % + (length, input_chunk_size)) if allow_short: if length < input_chunk_size: # padding