Taras Ledkov created COMPRESS-254:
-------------------------------------

             Summary: 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.6, 1.5, 1.4, 1.3
         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)

Reply via email to