COMPRESS-278 all empty numeric fields should be ignored in tars
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/compress/trunk@1588618 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index c9a7ec1..eb24ae7 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -74,6 +74,10 @@
<action type="fix" date="2014-04-18" issue="COMPRESS-273">
Added a few null checks to improve robustness.
</action>
+ <action type="fix" date="2014-04-19" issue="COMPRESS-278">
+ TarArchiveInputStream failed to read archives with empty
+ gid/uid fields.
+ </action>
</release>
<release version="1.8" date="2014-03-12"
description="Release 1.8">
diff --git a/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java b/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java
index 4cf32d6..1782ffe 100644
--- a/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java
+++ b/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java
@@ -130,10 +130,6 @@
end--;
trailer = buffer[end - 1];
}
- if (start == end) {
- throw new IllegalArgumentException(
- exceptionMessage(buffer, offset, length, start, trailer));
- }
for ( ;start < end; start++) {
final byte currentByte = buffer[start];
diff --git a/src/test/java/org/apache/commons/compress/archivers/tar/TarUtilsTest.java b/src/test/java/org/apache/commons/compress/archivers/tar/TarUtilsTest.java
index 7d6eb77..9210c54 100644
--- a/src/test/java/org/apache/commons/compress/archivers/tar/TarUtilsTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/tar/TarUtilsTest.java
@@ -64,6 +64,9 @@
buffer=new byte[]{0,' '};
value = TarUtils.parseOctal(buffer,0, buffer.length);
assertEquals(0, value);
+ buffer=new byte[]{' ',0};
+ value = TarUtils.parseOctal(buffer,0, buffer.length);
+ assertEquals(0, value);
}
public void testParseOctalInvalid() throws Exception{
@@ -80,12 +83,6 @@
fail("Expected IllegalArgumentException - should be at least 2 bytes long");
} catch (IllegalArgumentException expected) {
}
- buffer=new byte[]{' ',0,0,0}; // not all NULs
- try {
- TarUtils.parseOctal(buffer,0, buffer.length);
- fail("Expected IllegalArgumentException - not all NULs");
- } catch (IllegalArgumentException expected) {
- }
buffer = "abcdef ".getBytes(CharsetNames.UTF_8); // Invalid input
try {
TarUtils.parseOctal(buffer,0, buffer.length);