Return-Path: X-Original-To: apmail-commons-user-archive@www.apache.org Delivered-To: apmail-commons-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C6A394D7D for ; Fri, 17 Jun 2011 12:57:52 +0000 (UTC) Received: (qmail 37029 invoked by uid 500); 17 Jun 2011 12:57:51 -0000 Delivered-To: apmail-commons-user-archive@commons.apache.org Received: (qmail 36951 invoked by uid 500); 17 Jun 2011 12:57:50 -0000 Mailing-List: contact user-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Users List" Delivered-To: mailing list user@commons.apache.org Received: (qmail 36943 invoked by uid 99); 17 Jun 2011 12:57:50 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 17 Jun 2011 12:57:50 +0000 X-ASF-Spam-Status: No, hits=0.7 required=5.0 tests=SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [88.84.128.168] (HELO samaflost.de) (88.84.128.168) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 17 Jun 2011 12:57:44 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by samaflost.de (Postfix) with ESMTP id 63170289801D for ; Fri, 17 Jun 2011 14:57:23 +0200 (CEST) Received: from samaflost.de ([127.0.0.1]) by localhost (v35516.1blu.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Hgm2FrbVmxms for ; Fri, 17 Jun 2011 14:57:22 +0200 (CEST) Received: by samaflost.de (Postfix, from userid 1000) id B57A6289801E; Fri, 17 Jun 2011 14:57:22 +0200 (CEST) From: Stefan Bodewig To: user@commons.apache.org Subject: Re: [compress] any checksums in bz2 or gz tarballs? ... References: X-Draft-From: ("nnfolder:mail.commons-user" 1803) Date: Fri, 17 Jun 2011 14:57:22 +0200 In-Reply-To: (Albretch Mueller's message of "Wed, 15 Jun 2011 13:09:57 +0000") Message-ID: <87r56sipjh.fsf@v35516.1blu.de> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On 2011-06-15, Albretch Mueller wrote: > based on the data definifion of the struct holding TarArchiveEntry's > properties: > http://commons.apache.org/compress/apidocs/org/apache/commons/compress/archivers/tar/TarArchiveEntry.html > TarArchive entries, as zip ones, should have some checksum mechanism. > However, in the API I don't see a way to "get" it and "check" Commons Compress currently explicitly skips over the checksum field when parsing the tar entry, it doesn't check it, it doesn't even read it at all. So there not only is no way inside the API to access it, Commons Compress completely ignores it when reading. Things are different when Commons Compress writes tar archives as it computes the checksum and writes it. > Zip files hace Adler and/or CRC32 checksums The algorithm used in tar's is way less advanced, at least if the implementation on Commons Compress is correct, which I believe it to be. If I read the code correctly the checksum (unlike that in ZIPs) doesn't apply to the entry's contents but only to the header data which limits its usefulness. [This is from TarUtils.java] private static final int BYTE_MASK = 255; /** * Compute the checksum of a tar entry header. * * @param buf The tar entry's header buffer. * @return The computed checksum. */ public static long computeCheckSum(final byte[] buf) { long sum = 0; for (int i = 0; i < buf.length; ++i) { sum += BYTE_MASK & buf[i]; } return sum; } Stefan --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@commons.apache.org For additional commands, e-mail: user-help@commons.apache.org