From c59940852b94ba458cd5e3565e2679dc6af5d21f Mon Sep 17 00:00:00 2001 From: Zooko O'Whielacronx Date: Mon, 9 Feb 2009 23:46:05 -0700 Subject: [PATCH] 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.) --- src/allmydata/immutable/encode.py | 3 +++ 1 file changed, 3 insertions(+) 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 -- 2.45.2