Browse Source

port tar fix from commons compress

master
Stefan Bodewig 9 years ago
parent
commit
faa26a012e
2 changed files with 14 additions and 1 deletions
  1. +3
    -0
      WHATSNEW
  2. +11
    -1
      src/main/org/apache/tools/tar/TarInputStream.java

+ 3
- 0
WHATSNEW View File

@@ -38,6 +38,9 @@ Fixed bugs:
getting executed twice.
Bugzilla Report 58886

* TarInputStream now properly extraxt directory entries with a
non-zero size.

Other changes:
--------------



+ 11
- 1
src/main/org/apache/tools/tar/TarInputStream.java View File

@@ -177,6 +177,9 @@ public class TarInputStream extends FilterInputStream {
*/
@Override
public int available() throws IOException {
if (isDirectory()) {
return 0;
}
if (entrySize - entryOffset > Integer.MAX_VALUE) {
return Integer.MAX_VALUE;
}
@@ -195,6 +198,9 @@ public class TarInputStream extends FilterInputStream {
*/
@Override
public long skip(long numToSkip) throws IOException {
if (numToSkip <= 0 || isDirectory()) {
return 0;
}
// REVIEW
// This is horribly inefficient, but it ensures that we
// properly skip over bytes via the TarBuffer...
@@ -563,7 +569,7 @@ public class TarInputStream extends FilterInputStream {
public int read(byte[] buf, int offset, int numToRead) throws IOException {
int totalRead = 0;

if (entryOffset >= entrySize) {
if (entryOffset >= entrySize || isDirectory()) {
return -1;
}

@@ -656,5 +662,9 @@ public class TarInputStream extends FilterInputStream {
public boolean canReadEntryData(TarEntry te) {
return !te.isGNUSparse();
}

private boolean isDirectory() {
return currEntry != null && currEntry.isDirectory();
}
}


Loading…
Cancel
Save