Return-Path: X-Original-To: apmail-ant-dev-archive@www.apache.org Delivered-To: apmail-ant-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 430BB189E8 for ; Tue, 21 Jul 2015 02:23:17 +0000 (UTC) Received: (qmail 44490 invoked by uid 500); 21 Jul 2015 02:23:17 -0000 Delivered-To: apmail-ant-dev-archive@ant.apache.org Received: (qmail 44415 invoked by uid 500); 21 Jul 2015 02:23:17 -0000 Mailing-List: contact dev-help@ant.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Ant Developers List" Reply-To: "Ant Developers List" Delivered-To: mailing list dev@ant.apache.org Received: (qmail 44403 invoked by uid 99); 21 Jul 2015 02:23:16 -0000 Received: from Unknown (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 21 Jul 2015 02:23:16 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 2696618A309 for ; Tue, 21 Jul 2015 02:23:16 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -1.209 X-Spam-Level: X-Spam-Status: No, score=-1.209 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_MSPIKE_H2=-1.108, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd3-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-eu-west.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id D1d3VB5awvpS for ; Tue, 21 Jul 2015 02:23:15 +0000 (UTC) Received: from mail-ig0-f176.google.com (mail-ig0-f176.google.com [209.85.213.176]) by mx1-eu-west.apache.org (ASF Mail Server at mx1-eu-west.apache.org) with ESMTPS id 8915B21143 for ; Tue, 21 Jul 2015 02:23:14 +0000 (UTC) Received: by igr7 with SMTP id 7so28756154igr.0 for ; Mon, 20 Jul 2015 19:23:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=Ji5b3MqcjCeTJ0N7i+SYDKacqpO3+phJIl14Dve0vac=; b=LqX980ZRiK3OHcUyNLLHnkXAhEHqjHc6eUS8bZnFtcDJvhu1qabcfjRqKwH38RnHXA hCQ/AUUdWy+D8HE2Qgs3SztiGDGsrgwpCjYQ0PH2u0bODA1Dsskc7fTrfWA3HT1i9Yna dbsVHungTJE1DpcgaZq4KSXXCO8Vwo8z9Ps3QVMh30DSdz87pAw20Lk4pUbyMRWIQ94J zFezcZYLL3qqNqsGiinIUt+MAH5pCHEo1TlpVCt+fIXRrW1myQLoVYKCLK5OOAyHdyvA +VBMUNbK7JkLyJJOe0d+4JLrtfEPg5wQPOEnohiMt5Yo/dIKph1u5BNDN4Fj7JEkFNDp uFVw== MIME-Version: 1.0 X-Received: by 10.50.43.230 with SMTP id z6mr20101879igl.64.1437445393540; Mon, 20 Jul 2015 19:23:13 -0700 (PDT) Received: by 10.36.203.130 with HTTP; Mon, 20 Jul 2015 19:23:13 -0700 (PDT) In-Reply-To: References: Date: Mon, 20 Jul 2015 21:23:13 -0500 Message-ID: Subject: Re: ZipOutputStream exception in Ant 1.9.5 and 1.9.6 From: Earl Hood To: Ant Developers List Content-Type: text/plain; charset=UTF-8 On Mon, Jul 20, 2015 at 3:56 PM, I wrote: > I have a program that uses Ant's ZipOutputStream class, and it has had > no problems with versions of Ant 1.9.4 and earlier. However, with Ant > 1.9.5 and 1.9.6, I get the following exception: > > java.lang.ArrayIndexOutOfBoundsException > at java.lang.System.arraycopy(Native Method) > at org.apache.tools.zip.ZipOutputStream.createCentralFileHeader(ZipOutputStream.java:1264) > at org.apache.tools.zip.ZipOutputStream.createCentralFileHeader(ZipOutputStream.java:1178) > at org.apache.tools.zip.ZipOutputStream.writeCentralDirectoryInChunks(ZipOutputStream.java:513) > at org.apache.tools.zip.ZipOutputStream.finish(ZipOutputStream.java:498) > at org.apache.tools.zip.ZipOutputStream.close(ZipOutputStream.java:940) > at com.pbmassoc.nsiv.util.ZipDMs.zipFlattenDMs(ZipDMs.java:102) > at com.pbmassoc.nsiv.util.ZipDMs.main(ZipDMs.java:174) > ...snip... I believe I found the source of the problem. The problem is in the createCentralFileHeader() method on line 1261 of org/apache/tools/zip/ZipOutputStream.java: int commentStart = extraStart + commentLen; I think it should be: int commentStart = extraStart + extra.length; When I made the change in the 1.9.6 source bundle and built from source, I no longer got the error and the zip file created verifies with unzip and 7zip. It appears that Ant's core code never calls ZipEntry.setComment(), hence this bug was overlooked. Since the project I am on requires the ability to work with official releases of Ant, I will comment out the setComment() call in the project code; comments are not needed for our application to function. Hopefully, the above change can be incorporated into the Ant codebase. --ewh --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org For additional commands, e-mail: dev-help@ant.apache.org