This is an automated email from the ASF dual-hosted git repository.

bodewig pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git


The following commit(s) were added to refs/heads/master by this push:
     new f161254  COMPRESS-477 fix writing the number of entries to the EOCD 
record
f161254 is described below

commit f16125435723d143183c9c45fd3a0f92bdf97ba3
Author: Stefan Bodewig <[email protected]>
AuthorDate: Sun Jan 5 16:07:54 2020 +0100

    COMPRESS-477 fix writing the number of entries to the EOCD record
---
 .../compress/archivers/zip/ZipArchiveOutputStream.java        | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git 
a/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
 
b/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
index 345a5ad..0ad4f8b 100644
--- 
a/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
+++ 
b/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
@@ -1485,7 +1485,9 @@ public class ZipArchiveOutputStream extends 
ArchiveOutputStream {
         }
 
         // total number of entries in the central directory on this disk
-        int numOfEntriesOnThisDisk = 
numberOfCDInDiskData.get(numberOfThisDisk) == null ? 0 : 
numberOfCDInDiskData.get(numberOfThisDisk);
+        int numOfEntriesOnThisDisk = isSplitZip
+            ? (numberOfCDInDiskData.get(numberOfThisDisk) == null ? 0 : 
numberOfCDInDiskData.get(numberOfThisDisk))
+            : numberOfEntries;
         final byte[] numOfEntriesOnThisDiskData = ZipShort
                 .getBytes(Math.min(numOfEntriesOnThisDisk, ZIP64_MAGIC_SHORT));
         writeCounted(numOfEntriesOnThisDiskData);
@@ -1568,9 +1570,10 @@ public class ZipArchiveOutputStream extends 
ArchiveOutputStream {
         writeOut(ZipLong.getBytes(cdDiskNumberStart));
 
         // total number of entries in the central directory on this disk
-        int numOfEntriesOnThisDisk = 
numberOfCDInDiskData.get(numberOfThisDisk) == null ? 0 : 
numberOfCDInDiskData.get(numberOfThisDisk);
-        final byte[] numOfEntriesOnThisDiskData = ZipEightByteInteger
-                .getBytes(Math.min(numOfEntriesOnThisDisk, ZIP64_MAGIC_SHORT));
+        int numOfEntriesOnThisDisk = isSplitZip
+            ? (numberOfCDInDiskData.get(numberOfThisDisk) == null ? 0 : 
numberOfCDInDiskData.get(numberOfThisDisk))
+            : entries.size();
+        final byte[] numOfEntriesOnThisDiskData = 
ZipEightByteInteger.getBytes(numOfEntriesOnThisDisk);
         writeOut(numOfEntriesOnThisDiskData);
 
         // number of entries

Reply via email to