Permalink
Browse files

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.
  • Loading branch information...
moxie0 committed Aug 10, 2013
1 parent 4722b7f commit 8281ef18d42ec309a2f8fa08a03510af2b172eb6
Showing with 1 addition and 1 deletion.
  1. +1 −1 src/org/thoughtcrime/securesms/crypto/DecryptingPartInputStream.java
@@ -126,7 +126,7 @@ private int readIncremental(byte[] buffer, int offset, int length) throws IOExce
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 {

0 comments on commit 8281ef1

Please sign in to comment.