You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Stefan Bodewig (JIRA)" <ji...@apache.org> on 2014/01/14 08:42:56 UTC
[jira] [Commented] (COMPRESS-254) ZipArchiveOutputStream try to
switch to Zip64 when entries count over 64K entries
[ https://issues.apache.org/jira/browse/COMPRESS-254?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13870485#comment-13870485 ]
Stefan Bodewig commented on COMPRESS-254:
-----------------------------------------
When not using Zip64 you are limited to 65535 entries or you create invalid ZIP archives. See section 4.3.16 in http://www.pkware.com/documents/casestudies/APPNOTE.TXT where there are only two bytes for "total number of entries in the central directory". So when we introduced Zip64 support we plugged a hole that allowed Compress to create invalid archives.
> ZipArchiveOutputStream try to switch to Zip64 when entries count over 64K entries
> ---------------------------------------------------------------------------------
>
> Key: COMPRESS-254
> URL: https://issues.apache.org/jira/browse/COMPRESS-254
> Project: Commons Compress
> Issue Type: Bug
> Components: Archivers
> Affects Versions: 1.3, 1.4, 1.5, 1.6
> Environment: Unzip version < 6.0 (without Zip64 support)
> Reporter: Taras Ledkov
>
> Since version 1.3 we cannot create zip archive that contains over then 64K entries & without Zip64 extension.
> In case Zip64Mode.AsNeed is used target zip file cannot be open by unzip older then version 6.0.
> In case Zip64Mode.Never is used exception is thrown.
> Why so strong restriction as (ZipConstants,ZIP64_MAGIC_SHORT = 0xFFFF) was happened?
> To reproduce you can use dummy test below & [old unzip binaries|ftp://ftp.info-zip.org/pub/infozip/unix/]:
> {code:title=TestHuge}
> import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
> import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream;
> import java.io.File;
> import java.io.FileOutputStream;
> import java.io.IOException;
> import java.io.OutputStream;
> public class TestHuge {
> public static void main(String[] args) throws IOException {
> try(OutputStream os = new FileOutputStream(new File("test.zip"));
> ZipArchiveOutputStream zos = new ZipArchiveOutputStream(os)) {
> zos.setLevel(0);
> for (int dirCount = 0; dirCount < 10; ++dirCount) {
> ZipArchiveEntry entryDir = new ZipArchiveEntry("dir" + dirCount + "/");
> zos.putArchiveEntry(entryDir);
> zos.closeArchiveEntry();
> for (int i = 0; i < 0x4000; ++i) {
> ZipArchiveEntry entryFile = new ZipArchiveEntry("dir" + dirCount + "/" + "file" + i);
> zos.putArchiveEntry(entryFile);
> zos.write(("" + dirCount + " " + i).getBytes());
> zos.closeArchiveEntry();
> }
> }
> zos.finish();
> }
> }
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)