Author: fanningpj
Date: Fri Feb  7 21:44:50 2025
New Revision: 1923647

URL: http://svn.apache.org/viewvc?rev=1923647&view=rev
Log:
[bug-69563] try to avoid int overflow in Zip64 code (probably just moves the 
problem somewhere else though)

Modified:
    
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/OpcOutputStream.java
    
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/Zip64Impl.java

Modified: 
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/OpcOutputStream.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/OpcOutputStream.java?rev=1923647&r1=1923646&r2=1923647&view=diff
==============================================================================
--- 
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/OpcOutputStream.java
 (original)
+++ 
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/OpcOutputStream.java
 Fri Feb  7 21:44:50 2025
@@ -37,7 +37,7 @@ class OpcOutputStream extends DeflaterOu
     private final List<Entry> entries = new ArrayList<>();
     private final CRC32 crc = new CRC32();
     private Entry current;
-    private int written = 0;
+    private long written = 0;
     private boolean finished = false;
 
     /**
@@ -84,7 +84,7 @@ class OpcOutputStream extends DeflaterOu
         }
 
         current.size = def.getBytesRead();
-        current.compressedSize = Math.toIntExact(def.getBytesWritten());
+        current.compressedSize = def.getBytesWritten();
         current.crc = crc.getValue();
 
         written += current.compressedSize;
@@ -106,7 +106,7 @@ class OpcOutputStream extends DeflaterOu
         if(current != null) {
             closeEntry();
         }
-        int offset = written;
+        long offset = written;
         for (Entry entry : entries) {
             written += spec.writeCEN(entry);
         }

Modified: 
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/Zip64Impl.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/Zip64Impl.java?rev=1923647&r1=1923646&r2=1923647&view=diff
==============================================================================
--- 
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/Zip64Impl.java 
(original)
+++ 
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/Zip64Impl.java 
Fri Feb  7 21:44:50 2025
@@ -46,8 +46,8 @@ class Zip64Impl {
         final String filename;
         long crc;
         long size;
-        int compressedSize;
-        int offset;
+        long compressedSize;
+        long offset;
 
         Entry(String filename) {
             this.filename = filename;
@@ -128,7 +128,7 @@ class Zip64Impl {
     /**
      * Write End of central directory record (EOCD)
      */
-    int writeEND(int entriesCount, int offset, int length) throws IOException {
+    int writeEND(int entriesCount, long offset, long length) throws 
IOException {
         written = 0;
         writeInt(PK0506);         // "PK\005\006"
         writeShort(0);         // number of this disk



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to