basinilya opened a new pull request, #856:
URL: https://github.com/apache/commons-compress/pull/856

   <!--
     Licensed to the Apache Software Foundation (ASF) under one
     or more contributor license agreements.  See the NOTICE file
     distributed with this work for additional information
     regarding copyright ownership.  The ASF licenses this file
     to you under the Apache License, Version 2.0 (the
     "License"); you may not use this file except in compliance
     with the License.  You may obtain a copy of the License at
   
       https://www.apache.org/licenses/LICENSE-2.0
   
     Unless required by applicable law or agreed to in writing,
     software distributed under the License is distributed on an
     "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
     KIND, either express or implied.  See the License for the
     specific language governing permissions and limitations
     under the License.
   -->
   
   Dear Community. Previously, I sent a letter (which you can find below) about 
a possible bug in commons-compress. This PR is intended to collect test 
results. The new unit test compresses a huge amount of data and runs for dozens 
of seconds and I don't expect this to be accepted.
   
   I did use MS Copilot with GPT-6.1 to port the native method 
`java.util.zip.ZipFile.open()` (`zip_util.c`) to java language for reproducible 
results on different JREs.
   
   This PR adds `ZipJavaUtilZip64CompatibilityTest` that will compress a huge 
text file into a small zip file and then try to open it with an emulated 
`java.util.zip.ZipFile` 1.8.0.181 (JUZ). It creates two zip files: one with 
Apache and the other one with JUZ. The entry size is 4GiB + 1 byte. The 
resulting archive size is some 4MB. The JUZ archive is opened successfully. The 
Apache archive currently fails (rel/commons-compress-1.28.0-1045-ga70796b73). 
It will also try to open the archives with the real JUZ but the most recent 
java 8 version 1.8.0.514 can handle both archives.
   
   This PR also adds `ZipJavaUtilFixtureCompatibilityTest` and a 2KB 
`huge-entry-in-small.zip.7z` to test the emulated `java.util.zip.ZipFile` 
1.8.0.181 itself.
   
   The e-mail thread:
   
   ```
   Sent: Wednesday, November 19, 2025 at 9:24 PM UTC+3
   To: [email protected]
   Subject: ZipArchiveOutputStream: quirk to omit Zip64CentralDirectory if 
resulting file will be smaller than 4gb
   
   Hi List.
   Perhaps it was discusssed already, but I couldn't find it.
   
   We still have software running on java 8 and java.util.zip.ZipFile can't 
open small zips if some entries have huge uncompressed size. Same archives can 
be opened on java 24 without problem. This happens with zips created with 
ZipArchiveOutputStream, if repacked with 7zip it works even with java 8.
   
   I see that both 7zip and Commons enable zip64 extensions in the entries, but 
7zip doesn't create the zip64 headers in the central directory.
   
   For same input data, if I pause the debugger at the beginning of 
ZipArchiveOutputStream.writeZip64CentralDirectory() and clear the 
"hasUsedZip64" flag, the file can be opened by java 8!
   
   What do you think? Can we add a quirk to omit Zip64CentralDirectory if the 
resulting file would be small enough?
   ================================================
   ================================================
   From: Gary Gregory <[email protected]>
   Sent: Wednesday, November 19, 2025 at 11:30 PM UTC+3
   To: Commons Developers List <[email protected]>
   Subject: RE: ZipArchiveOutputStream: quirk to omit Zip64CentralDirectory if 
resulting file will be smaller than 4gb
   
   Hello,
   
   Please provide a failing unit test, then we can see exactly what we're
   dealing with.
   
   You can do this as a PR on GitHub which should fail on Java 8 and it sounds
   like it will pass on 25. Our GH CI is set up to run on all Java LTS
   versions so it should show up.
   
   Thank you,
   Gary
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to