Skip to content

Commit b2b12f1

Browse files
committed
Fix Implicit narrowing conversion in compound assignment
Currently we add a long to an int this can result in information loss and numeric errors such as overflows. As we only skip an integer amount of bytes the result can also only be an int of bytes skipped, adding an explicit cast makes the security scanner happy here.
1 parent 1478eca commit b2b12f1

File tree

1 file changed

+8
-8
lines changed
  • apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/util

1 file changed

+8
-8
lines changed

apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/util/TarFile.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@
3030
*/
3131
public class TarFile implements Closeable {
3232
private static class TarInputStream extends FilterInputStream {
33-
private int nextEntry = 0;
34-
private int nextEOF = 0;
35-
private int filepos = 0;
36-
private int bytesread = 0;
37-
private TarEntry firstEntry = null;
38-
private String longLinkName = null;
33+
private int nextEntry;
34+
private int nextEOF;
35+
private int filepos;
36+
private int bytesread;
37+
private TarEntry firstEntry;
38+
private String longLinkName;
3939

4040
/**
4141
* Creates a new tar input stream on the given input stream.
@@ -87,7 +87,7 @@ boolean skipToEntry(TarEntry entry) throws TarException, IOException {
8787
return false;
8888
}
8989
while (bytestoskip > 0) {
90-
long ret = in.skip(bytestoskip);
90+
int ret = (int) in.skip(bytestoskip);
9191
if (ret < 0) {
9292
throw new IOException("early end of stream"); //$NON-NLS-1$
9393
}
@@ -162,7 +162,7 @@ TarEntry getNextEntryInternal() throws TarException, IOException {
162162
}
163163

164164
while (nextEntry > 0) {
165-
long ret = in.skip(nextEntry);
165+
int ret = (int) in.skip(nextEntry);
166166
if (ret < 0) {
167167
throw new IOException("early end of stream"); //$NON-NLS-1$
168168
}

0 commit comments

Comments
 (0)