ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <bode...@apache.org>
Subject Re: ZipOutputStream exception in Ant 1.9.5 and 1.9.6
Date Tue, 21 Jul 2015 04:16:49 GMT
On 2015-07-21, Earl Hood wrote:

> 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;

You are correct.  I'll sit down and review the merged changes
thoroughly once again.

> It appears that Ant's core code never calls ZipEntry.setComment(), hence
> this bug was overlooked.

... and should only affect people using Ant's zip classes as a library.
We encourage people to use Commons Compress instead.  Of course
Compress' trunk contained the same bug ...

> 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.

It has been committed, many thanks.

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message