Repository: commons-compress Updated Branches: refs/heads/master 9431b16c5 -> 7250daa42
COMPRESS-335 yet another strange case of tar checksum Project: http://git-wip-us.apache.org/repos/asf/commons-compress/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-compress/commit/7250daa4 Tree: http://git-wip-us.apache.org/repos/asf/commons-compress/tree/7250daa4 Diff: http://git-wip-us.apache.org/repos/asf/commons-compress/diff/7250daa4 Branch: refs/heads/master Commit: 7250daa429020181bb5a4c40d1aaa169631b8496 Parents: 9431b16 Author: Stefan Bodewig <[email protected]> Authored: Fri Feb 5 21:20:19 2016 +0100 Committer: Stefan Bodewig <[email protected]> Committed: Fri Feb 5 21:20:19 2016 +0100 ---------------------------------------------------------------------- src/changes/changes.xml | 4 ++++ .../commons/compress/archivers/tar/TarUtils.java | 7 +------ .../commons/compress/DetectArchiverTestCase.java | 7 +++++++ src/test/resources/COMPRESS-335.tar | Bin 0 -> 3072 bytes 4 files changed, 12 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-compress/blob/7250daa4/src/changes/changes.xml ---------------------------------------------------------------------- diff --git a/src/changes/changes.xml b/src/changes/changes.xml index a513026..5612f69 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -44,6 +44,10 @@ The <action> type attribute can be add,update,fix,remove. <body> <release version="1.11" date="not released, yet" description="Release 1.11"> + <action issue="COMPRESS-335" type="fix" date="2016-02-05"> + checksums of tars that pad the checksum field to the left are + now calculated properly. + </action> <action issue="COMPRESS-334" type="fix" date="2016-02-05" due-to="Jeremy Gustie"> ArArchiveInputStream failed to read past the first entry when http://git-wip-us.apache.org/repos/asf/commons-compress/blob/7250daa4/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java ---------------------------------------------------------------------- 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 65088eb..204debf 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 @@ -591,7 +591,7 @@ public class TarUtils { * @since 1.5 */ public static boolean verifyCheckSum(byte[] header) { - long storedSum = 0; + long storedSum = parseOctal(header, CHKSUM_OFFSET, CHKSUMLEN); long unsignedSum = 0; long signedSum = 0; @@ -599,11 +599,6 @@ public class TarUtils { for (int i = 0; i < header.length; i++) { byte b = header[i]; if (CHKSUM_OFFSET <= i && i < CHKSUM_OFFSET + CHKSUMLEN) { - if ('0' <= b && b <= '7' && digits++ < 6) { - storedSum = storedSum * 8 + b - '0'; - } else if (digits > 0) { - digits = 6; // only look at the first octal digit sequence - } b = ' '; } unsignedSum += 0xff & b; http://git-wip-us.apache.org/repos/asf/commons-compress/blob/7250daa4/src/test/java/org/apache/commons/compress/DetectArchiverTestCase.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/compress/DetectArchiverTestCase.java b/src/test/java/org/apache/commons/compress/DetectArchiverTestCase.java index ad18902..8e1e7bf 100644 --- a/src/test/java/org/apache/commons/compress/DetectArchiverTestCase.java +++ b/src/test/java/org/apache/commons/compress/DetectArchiverTestCase.java @@ -56,6 +56,13 @@ public final class DetectArchiverTestCase extends AbstractTestCase { } @Test + public void testCOMPRESS335() throws Exception { + final ArchiveInputStream tar = getStreamFor("COMPRESS-335.tar"); + assertNotNull(tar); + assertTrue(tar instanceof TarArchiveInputStream); + } + + @Test public void testDetection() throws Exception { final ArchiveInputStream ar = getStreamFor("bla.ar"); http://git-wip-us.apache.org/repos/asf/commons-compress/blob/7250daa4/src/test/resources/COMPRESS-335.tar ---------------------------------------------------------------------- diff --git a/src/test/resources/COMPRESS-335.tar b/src/test/resources/COMPRESS-335.tar new file mode 100644 index 0000000..0266b63 Binary files /dev/null and b/src/test/resources/COMPRESS-335.tar differ
