mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-05-04 15:35:38 +01:00
Take padded bytes into account when decrypting a stream of data.
Fixes #11573
This commit is contained in:
committed by
Cody Henthorne
parent
cc99febe32
commit
e18d9e665f
+4
-2
@@ -162,10 +162,12 @@ public class AttachmentCipherInputStream extends FilterInputStream {
|
||||
|
||||
private int readFinal(byte[] buffer, int offset, int length) throws IOException {
|
||||
try {
|
||||
int flourish = cipher.doFinal(buffer, offset);
|
||||
byte[] internal = new byte[buffer.length];
|
||||
int actualLength = Math.min(length, cipher.doFinal(internal, 0));
|
||||
System.arraycopy(internal, 0, buffer, offset, actualLength);
|
||||
|
||||
done = true;
|
||||
return flourish;
|
||||
return actualLength;
|
||||
} catch (IllegalBlockSizeException | BadPaddingException | ShortBufferException e) {
|
||||
throw new IOException(e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user