fix integer overflows

* available() method in ChunkFileInputStream.java
* free "ahead space" calculation in CircularFileWriter.java
This commit is contained in:
kapodamy 2020-04-01 15:11:57 -03:00
parent 96086b7733
commit 62d934dd8e
2 changed files with 2 additions and 2 deletions

View File

@ -104,7 +104,7 @@ public class ChunkFileInputStream extends SharpStream {
@Override
public long available() {
return (int) (length - position);
return length - position;
}
@SuppressWarnings("EmptyCatchBlock")

View File

@ -221,7 +221,7 @@ public class CircularFileWriter extends SharpStream {
available = out.length - offsetOut;
}
int length = Math.min(len, (int) available);
int length = Math.min(len, (int) Math.min(Integer.MAX_VALUE, available));
out.write(b, off, length);
len -= length;