Return-Path: X-Original-To: apmail-commons-commits-archive@minotaur.apache.org Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 49D8C187C4 for ; Fri, 5 Feb 2016 20:20:59 +0000 (UTC) Received: (qmail 83108 invoked by uid 500); 5 Feb 2016 20:20:49 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 83028 invoked by uid 500); 5 Feb 2016 20:20:49 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 83019 invoked by uid 99); 5 Feb 2016 20:20:49 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 05 Feb 2016 20:20:49 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 7044BDFF96; Fri, 5 Feb 2016 20:20:49 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: bodewig@apache.org To: commits@commons.apache.org Message-Id: <67f99f6bde184bdda7f83e76cd327b09@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: commons-compress git commit: COMPRESS-335 yet another strange case of tar checksum Date: Fri, 5 Feb 2016 20:20:49 +0000 (UTC) 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 Authored: Fri Feb 5 21:20:19 2016 +0100 Committer: Stefan Bodewig 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 type attribute can be add,update,fix,remove. + + checksums of tars that pad the checksum field to the left are + now calculated properly. + 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