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.
pull/1/head
Moxie Marlinspike 12 years ago
parent 4722b7f005
commit 8281ef18d4

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

Loading…
Cancel
Save