[jira] [Commented] (COMPRESS-538) ZipEntry created using ZipArchiveOutputStream(File) constructor adds 'ZIP64 Extended Information Extra Field' even when zip64 is not required.
[ https://issues.apache.org/jira/browse/COMPRESS-538?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17151045#comment-17151045 ] Stefan Bodewig commented on COMPRESS-538: - We can not remove the extra header from the LFH as we have already written the content of the entry to the stream after that. I think this is the best we can do. > ZipEntry created using ZipArchiveOutputStream(File) constructor adds 'ZIP64 > Extended Information Extra Field' even when zip64 is not required. > -- > > Key: COMPRESS-538 > URL: https://issues.apache.org/jira/browse/COMPRESS-538 > Project: Commons Compress > Issue Type: Bug > Components: Archivers >Affects Versions: 1.8, 1.9, 1.20 >Reporter: Pritesh >Assignee: Peter Lee >Priority: Major > > When creating a zip file using > [ZipArchiveOutputStream(File)|https://commons.apache.org/proper/commons-compress/apidocs/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.html#ZipArchiveOutputStream-java.io.File-] > constructor each entry get an extra `Zip64ExtendedInformationExtraField` > header which shouldn't be there. > > The issue can be reproduced using below code sample > {code:java} > public static void main(String[] args) throws IOException { > // Create file > final File file = File.createTempFile("apache_", ".zip"); > try ( ZipArchiveOutputStream zos = new ZipArchiveOutputStream(file)) { > zos.putArchiveEntry(new ZipArchiveEntry("TextFile1.txt")); > zos.closeArchiveEntry(); > } > // List Headers File > final ZipFile zipFile = new ZipFile(file); > final Enumeration entries = > zipFile.getEntries(); > while (entries.hasMoreElements()) { > final ZipArchiveEntry entry = entries.nextElement(); > for (ZipExtraField zipExtraField : entry.getExtraFields()) { > System.out.println("EntryName:" + entry.getName() + " Header: > "+ zipExtraField.getHeaderId().getValue()); // Header shouldn't be present. > } > } > } > {code} -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Commented] (COMPRESS-538) ZipEntry created using ZipArchiveOutputStream(File) constructor adds 'ZIP64 Extended Information Extra Field' even when zip64 is not required.
[ https://issues.apache.org/jira/browse/COMPRESS-538?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17143694#comment-17143694 ] Peter Lee commented on COMPRESS-538: I have found out what's wrong here : the extra fields was removed but the extra field length was not updated. Will try to fix this ASAP. > ZipEntry created using ZipArchiveOutputStream(File) constructor adds 'ZIP64 > Extended Information Extra Field' even when zip64 is not required. > -- > > Key: COMPRESS-538 > URL: https://issues.apache.org/jira/browse/COMPRESS-538 > Project: Commons Compress > Issue Type: Bug > Components: Archivers >Affects Versions: 1.8, 1.9, 1.20 >Reporter: Pritesh >Assignee: Peter Lee >Priority: Major > > When creating a zip file using > [ZipArchiveOutputStream(File)|https://commons.apache.org/proper/commons-compress/apidocs/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.html#ZipArchiveOutputStream-java.io.File-] > constructor each entry get an extra `Zip64ExtendedInformationExtraField` > header which shouldn't be there. > > The issue can be reproduced using below code sample > {code:java} > public static void main(String[] args) throws IOException { > // Create file > final File file = File.createTempFile("apache_", ".zip"); > try ( ZipArchiveOutputStream zos = new ZipArchiveOutputStream(file)) { > zos.putArchiveEntry(new ZipArchiveEntry("TextFile1.txt")); > zos.closeArchiveEntry(); > } > // List Headers File > final ZipFile zipFile = new ZipFile(file); > final Enumeration entries = > zipFile.getEntries(); > while (entries.hasMoreElements()) { > final ZipArchiveEntry entry = entries.nextElement(); > for (ZipExtraField zipExtraField : entry.getExtraFields()) { > System.out.println("EntryName:" + entry.getName() + " Header: > "+ zipExtraField.getHeaderId().getValue()); // Header shouldn't be present. > } > } > } > {code} -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Commented] (COMPRESS-538) ZipEntry created using ZipArchiveOutputStream(File) constructor adds 'ZIP64 Extended Information Extra Field' even when zip64 is not required.
[ https://issues.apache.org/jira/browse/COMPRESS-538?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17141969#comment-17141969 ] Peter Lee commented on COMPRESS-538: Ah, I see. Will look deeper here. A bit busy recently ... hope I could carve out some time this week for this. :) > ZipEntry created using ZipArchiveOutputStream(File) constructor adds 'ZIP64 > Extended Information Extra Field' even when zip64 is not required. > -- > > Key: COMPRESS-538 > URL: https://issues.apache.org/jira/browse/COMPRESS-538 > Project: Commons Compress > Issue Type: Bug > Components: Archivers >Affects Versions: 1.8, 1.9, 1.20 >Reporter: Pritesh >Assignee: Peter Lee >Priority: Major > > When creating a zip file using > [ZipArchiveOutputStream(File)|https://commons.apache.org/proper/commons-compress/apidocs/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.html#ZipArchiveOutputStream-java.io.File-] > constructor each entry get an extra `Zip64ExtendedInformationExtraField` > header which shouldn't be there. > > The issue can be reproduced using below code sample > {code:java} > public static void main(String[] args) throws IOException { > // Create file > final File file = File.createTempFile("apache_", ".zip"); > try ( ZipArchiveOutputStream zos = new ZipArchiveOutputStream(file)) { > zos.putArchiveEntry(new ZipArchiveEntry("TextFile1.txt")); > zos.closeArchiveEntry(); > } > // List Headers File > final ZipFile zipFile = new ZipFile(file); > final Enumeration entries = > zipFile.getEntries(); > while (entries.hasMoreElements()) { > final ZipArchiveEntry entry = entries.nextElement(); > for (ZipExtraField zipExtraField : entry.getExtraFields()) { > System.out.println("EntryName:" + entry.getName() + " Header: > "+ zipExtraField.getHeaderId().getValue()); // Header shouldn't be present. > } > } > } > {code} -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Commented] (COMPRESS-538) ZipEntry created using ZipArchiveOutputStream(File) constructor adds 'ZIP64 Extended Information Extra Field' even when zip64 is not required.
[ https://issues.apache.org/jira/browse/COMPRESS-538?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17136447#comment-17136447 ] Pritesh commented on COMPRESS-538: -- Yes, specifying the file size does fix the issue but aren't we trying to remove ZIP64 extra at [ZipArchiveOutputStream#704?|http://commons.apache.org/proper/commons-compress/javadocs/api-1.18/src-html/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.html#704] for the 3rd case? In-fact, it does removes the field from ZipArchiveEntry's extraFields but fails to update ZipEntry's extra. > ZipEntry created using ZipArchiveOutputStream(File) constructor adds 'ZIP64 > Extended Information Extra Field' even when zip64 is not required. > -- > > Key: COMPRESS-538 > URL: https://issues.apache.org/jira/browse/COMPRESS-538 > Project: Commons Compress > Issue Type: Bug > Components: Archivers >Affects Versions: 1.8 >Reporter: Pritesh >Assignee: Peter Lee >Priority: Major > > When creating a zip file using > [ZipArchiveOutputStream(File)|https://commons.apache.org/proper/commons-compress/apidocs/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.html#ZipArchiveOutputStream-java.io.File-] > constructor each entry get an extra `Zip64ExtendedInformationExtraField` > header which shouldn't be there. > > The issue can be reproduced using below code sample > {code:java} > public static void main(String[] args) throws IOException { > // Create file > final File file = File.createTempFile("apache_", ".zip"); > try ( ZipArchiveOutputStream zos = new ZipArchiveOutputStream(file)) { > zos.putArchiveEntry(new ZipArchiveEntry("TextFile1.txt")); > zos.closeArchiveEntry(); > } > // List Headers File > final ZipFile zipFile = new ZipFile(file); > final Enumeration entries = > zipFile.getEntries(); > while (entries.hasMoreElements()) { > final ZipArchiveEntry entry = entries.nextElement(); > for (ZipExtraField zipExtraField : entry.getExtraFields()) { > System.out.println("EntryName:" + entry.getName() + " Header: > "+ zipExtraField.getHeaderId().getValue()); // Header shouldn't be present. > } > } > } > {code} -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Commented] (COMPRESS-538) ZipEntry created using ZipArchiveOutputStream(File) constructor adds 'ZIP64 Extended Information Extra Field' even when zip64 is not required.
[ https://issues.apache.org/jira/browse/COMPRESS-538?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17136390#comment-17136390 ] Peter Lee commented on COMPRESS-538: Commons Compress will add zip64 extra field in the following cases: 1, The Zip64Mode is Zip64Mode.Always : you can modify this by entry.setUnixMode; 2, The uncompressed size or compressed size of the entry is large so we need to use zip64; 3, The uncompressed size of the entry is unknown and the Zip64Mode is NOT Zip64Mode.Never : we do not know the entry's uncompressed size, so we add a zip64 extra here in case of it's too large. In your particular testcase, you're experiencing the third case I have listed. You can simply avoid this by specifying the size of the file : {code:java} @Test public void testExtra() throws IOException { // Create file final File file = File.createTempFile("apache_", ".zip"); try ( ZipArchiveOutputStream zos = new ZipArchiveOutputStream(file)) { ZipArchiveEntry entry = new ZipArchiveEntry("TextFile1.txt"); entry.setSize(0); zos.putArchiveEntry(entry); zos.closeArchiveEntry(); } // List Headers File final ZipFile zipFile = new ZipFile(file); final Enumeration entries = zipFile.getEntries(); while (entries.hasMoreElements()) { final ZipArchiveEntry entry = entries.nextElement(); for (ZipExtraField zipExtraField : entry.getExtraFields()) { System.out.println("EntryName:" + entry.getName() + " Header: "+ zipExtraField.getHeaderId().getValue()); // Header shouldn't be present. } } } {code} BTW : the affected version you set is 1.8 but the latest release of Commons Compress is 1.20. I'm only testing this in 1.20. > ZipEntry created using ZipArchiveOutputStream(File) constructor adds 'ZIP64 > Extended Information Extra Field' even when zip64 is not required. > -- > > Key: COMPRESS-538 > URL: https://issues.apache.org/jira/browse/COMPRESS-538 > Project: Commons Compress > Issue Type: Bug > Components: Archivers >Affects Versions: 1.8 >Reporter: Pritesh >Priority: Major > > When creating a zip file using > [ZipArchiveOutputStream(File)|https://commons.apache.org/proper/commons-compress/apidocs/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.html#ZipArchiveOutputStream-java.io.File-] > constructor each entry get an extra `Zip64ExtendedInformationExtraField` > header which shouldn't be there. > > The issue can be reproduced using below code sample > {code:java} > public static void main(String[] args) throws IOException { > // Create file > final File file = File.createTempFile("apache_", ".zip"); > try ( ZipArchiveOutputStream zos = new ZipArchiveOutputStream(file)) { > zos.putArchiveEntry(new ZipArchiveEntry("TextFile1.txt")); > zos.closeArchiveEntry(); > } > // List Headers File > final ZipFile zipFile = new ZipFile(file); > final Enumeration entries = > zipFile.getEntries(); > while (entries.hasMoreElements()) { > final ZipArchiveEntry entry = entries.nextElement(); > for (ZipExtraField zipExtraField : entry.getExtraFields()) { > System.out.println("EntryName:" + entry.getName() + " Header: > "+ zipExtraField.getHeaderId().getValue()); // Header shouldn't be present. > } > } > } > {code} -- This message was sent by Atlassian Jira (v8.3.4#803005)