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.)
This commit is contained in:
Zooko O'Whielacronx 2009-02-09 23:46:05 -07:00
parent 1d13be3701
commit c59940852b

View File

@ -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