Fix for ShortBufferException problem introduced in Android 4.3

Not really sure how it's possible for the system to give us an
extra block of data, but it does if both the input and output
buffers are sized the same during the first decrypt.  This
fixes things, but I wish I better understood why it was broken.
This commit is contained in:
Moxie Marlinspike 2013-08-10 09:09:00 -07:00
parent 4722b7f005
commit 8281ef18d4

View File

@ -126,7 +126,7 @@ public class DecryptingPartInputStream extends FileInputStream {
length = (int)(totalDataSize - totalRead);
byte[] internalBuffer = new byte[length];
int read = super.read(internalBuffer, 0, internalBuffer.length);
int read = super.read(internalBuffer, 0, internalBuffer.length <= cipher.getBlockSize() ? internalBuffer.length : internalBuffer.length - cipher.getBlockSize());
totalRead += read;
try {