Skip to content

Commit

Permalink
TarInputStream: Prevent Implicit narrowing conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
BeckerWdf authored and laeubi committed Dec 16, 2023
1 parent c6e1094 commit e7a5b11
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class TarEntry implements Cloneable
private String name;
private long mode, time, size;
private int type;
int filepos;
long filepos;

/**
* Entry type for normal files.
Expand All @@ -42,7 +42,7 @@ public class TarEntry implements Cloneable
* @param name filename
* @param pos position in the file in bytes
*/
TarEntry(String name, int pos) {
TarEntry(String name, long pos) {
this.name = name;
mode = 0644;
type = FILE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
*/
public class TarInputStream extends FilterInputStream
{
private int nextEntry = 0;
private int nextEOF = 0;
private int filepos = 0;
private int bytesread = 0;
private long nextEntry = 0;
private long nextEOF = 0;
private long filepos = 0;
private long bytesread = 0;
private TarEntry firstEntry = null;
private String longLinkName = null;

Expand Down Expand Up @@ -79,7 +79,7 @@ private long headerChecksum(byte[] header) {
* @return false if the entry has already been passed
*/
boolean skipToEntry(TarEntry entry) throws TarException, IOException {
int bytestoskip = entry.filepos - bytesread;
long bytestoskip = entry.filepos - bytesread;
if(bytestoskip < 0) {
return false;
}
Expand Down Expand Up @@ -310,7 +310,7 @@ public int read(byte[] b, int off, int len) throws IOException {
return -1;
}
if(len > nextEOF) {
len = nextEOF;
len = (int) nextEOF;
}
int size = super.read(b, off, len);
nextEntry -= size;
Expand Down

0 comments on commit e7a5b11

Please sign in to comment.