Fix CipherInputStream seek behavior

Fixes #6518
// FREEBIE
pull/1/head
Moxie Marlinspike 7 years ago
parent 51f27631ef
commit fad697ba2a

@ -19,6 +19,7 @@ package org.thoughtcrime.securesms.crypto;
import android.util.Log;
import org.thoughtcrime.securesms.util.LimitedInputStream;
import org.thoughtcrime.securesms.util.Util;
import java.io.File;
import java.io.FileInputStream;
@ -139,5 +140,30 @@ public class DecryptingPartInputStream {
Log.w(TAG, t);
}
}
@Override
public long skip(long skipAmount)
throws IOException
{
long remaining = skipAmount;
if (skipAmount <= 0) {
return 0;
}
byte[] skipBuffer = new byte[4092];
while (remaining > 0) {
int read = super.read(skipBuffer, 0, Util.toIntExact(Math.min(skipBuffer.length, remaining)));
if (read < 0) {
break;
}
remaining -= read;
}
return skipAmount - remaining;
}
}
}

Loading…
Cancel
Save