Fix CipherInputStream seek behavior

Fixes #6518
// FREEBIE
This commit is contained in:
Moxie Marlinspike 2017-04-13 12:21:38 -07:00
parent 51f27631ef
commit fad697ba2a

View File

@ -19,6 +19,7 @@ package org.thoughtcrime.securesms.crypto;
import android.util.Log; import android.util.Log;
import org.thoughtcrime.securesms.util.LimitedInputStream; import org.thoughtcrime.securesms.util.LimitedInputStream;
import org.thoughtcrime.securesms.util.Util;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
@ -139,5 +140,30 @@ public class DecryptingPartInputStream {
Log.w(TAG, t); 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;
}
} }
} }