poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From talli...@apache.org
Subject svn commit: r1879097 - in /poi/trunk/src: java/org/apache/poi/util/IOUtils.java scratchpad/src/org/apache/poi/hwpf/HWPFDocumentCore.java
Date Mon, 22 Jun 2020 20:23:19 GMT
Author: tallison
Date: Mon Jun 22 20:23:19 2020
New Revision: 1879097

URL: http://svn.apache.org/viewvc?rev=1879097&view=rev
Log:
improve memory safety in HWPFDocumentCore

Modified:
    poi/trunk/src/java/org/apache/poi/util/IOUtils.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocumentCore.java

Modified: poi/trunk/src/java/org/apache/poi/util/IOUtils.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/util/IOUtils.java?rev=1879097&r1=1879096&r2=1879097&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/util/IOUtils.java (original)
+++ poi/trunk/src/java/org/apache/poi/util/IOUtils.java Mon Jun 22 20:23:19 2020
@@ -188,7 +188,7 @@ public final class IOUtils {
                 baos.write(buffer, 0, readBytes);
             }
 
-            checkByteSizeLimit(readBytes);
+            checkByteSizeLimit(totalBytes);
         } while (totalBytes < len && readBytes > -1);
 
         if (maxLength != Integer.MAX_VALUE && totalBytes == maxLength) {

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocumentCore.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocumentCore.java?rev=1879097&r1=1879096&r2=1879097&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocumentCore.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocumentCore.java Mon Jun 22 20:23:19
2020
@@ -67,7 +67,7 @@ public abstract class HWPFDocumentCore e
     protected static final String STREAM_TABLE_1 = "1Table";
 
     //arbitrarily selected; may need to increase
-    private static final int MAX_RECORD_LENGTH = 1_000_000;
+    private static final int MAX_RECORD_LENGTH = 500_000_000;
 
     /**
      * Size of the not encrypted part of the FIB
@@ -328,7 +328,7 @@ public abstract class HWPFDocumentCore e
 
         try (DocumentInputStream dis = dir.createDocumentInputStream(documentProps);
              InputStream is = isEncrypted ? getDecryptedStream(dis, streamSize, encryptionOffset)
: dis) {
-            return IOUtils.toByteArray(is, Math.min(streamSize, len));
+            return IOUtils.toByteArray(is, Math.min(streamSize, len), MAX_RECORD_LENGTH);
         } catch (GeneralSecurityException e) {
             throw new IOException("Unable to decrypt data for entry: "+name, e);
         }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message