You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bo...@apache.org on 2016/02/07 15:11:18 UTC

ant git commit: port tar fix from commons compress

Repository: ant
Updated Branches:
  refs/heads/master 7046631e9 -> faa26a012


port tar fix from commons compress


Project: http://git-wip-us.apache.org/repos/asf/ant/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/faa26a01
Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/faa26a01
Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/faa26a01

Branch: refs/heads/master
Commit: faa26a012ed8fcd58379a6cf45045d5b07ac02c2
Parents: 7046631
Author: Stefan Bodewig <bo...@apache.org>
Authored: Sun Feb 7 15:10:55 2016 +0100
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Sun Feb 7 15:10:55 2016 +0100

----------------------------------------------------------------------
 WHATSNEW                                          |  3 +++
 src/main/org/apache/tools/tar/TarInputStream.java | 12 +++++++++++-
 2 files changed, 14 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ant/blob/faa26a01/WHATSNEW
----------------------------------------------------------------------
diff --git a/WHATSNEW b/WHATSNEW
index ccf3548..b74181c 100644
--- a/WHATSNEW
+++ b/WHATSNEW
@@ -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:
 --------------
 

http://git-wip-us.apache.org/repos/asf/ant/blob/faa26a01/src/main/org/apache/tools/tar/TarInputStream.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/tar/TarInputStream.java b/src/main/org/apache/tools/tar/TarInputStream.java
index 57827a2..964e5c5 100644
--- a/src/main/org/apache/tools/tar/TarInputStream.java
+++ b/src/main/org/apache/tools/tar/TarInputStream.java
@@ -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();
+    }
 }