]> source.dussan.org Git - poi.git/commitdiff
more support for configurable max record len
authorPJ Fanning <fanningpj@apache.org>
Fri, 22 Oct 2021 21:08:53 +0000 (21:08 +0000)
committerPJ Fanning <fanningpj@apache.org>
Fri, 22 Oct 2021 21:08:53 +0000 (21:08 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1894494 13f79535-47bb-0310-9956-ffa450edef68

22 files changed:
poi-scratchpad/src/main/java/org/apache/poi/hemf/record/emf/HemfText.java
poi-scratchpad/src/main/java/org/apache/poi/hmef/dev/HMEFDumper.java
poi-scratchpad/src/main/java/org/apache/poi/hpbf/model/EscherPart.java
poi-scratchpad/src/main/java/org/apache/poi/hslf/record/AnimationInfoAtom.java
poi-scratchpad/src/main/java/org/apache/poi/hslf/record/Comment2000Atom.java
poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExHyperlinkAtom.java
poi-scratchpad/src/main/java/org/apache/poi/hslf/record/HeadersFootersAtom.java
poi-scratchpad/src/main/java/org/apache/poi/hslf/record/InteractiveInfoAtom.java
poi-scratchpad/src/main/java/org/apache/poi/hslf/record/PersistPtrHolder.java
poi-scratchpad/src/main/java/org/apache/poi/hslf/record/RecordAtom.java
poi-scratchpad/src/main/java/org/apache/poi/hslf/record/TextRulerAtom.java
poi-scratchpad/src/main/java/org/apache/poi/hslf/record/TextSpecInfoAtom.java
poi-scratchpad/src/main/java/org/apache/poi/hslf/record/TxMasterStyleAtom.java
poi-scratchpad/src/main/java/org/apache/poi/hwpf/HWPFDocument.java
poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/CHPFormattedDiskPage.java
poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/ComplexFileTable.java
poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/DocumentProperties.java
poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/Ffn.java
poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/FileInformationBlock.java
poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/PICFAndOfficeArtData.java
poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/SectionTable.java
poi/src/test/java9/module-info.class

index 9a8f629afcb2d185ec939a419a79a1df64aa56c5..b7b7ef698ca06c05f20273fbfdfd616ad5f1a307 100644 (file)
@@ -52,7 +52,22 @@ import org.apache.poi.util.RecordFormatException;
 @SuppressWarnings("WeakerAccess")
 public class HemfText {
 
-    private static final int MAX_RECORD_LENGTH = 1_000_000;
+    private static final int DEFAULT_MAX_RECORD_LENGTH = 1_000_000;
+    private static int MAX_RECORD_LENGTH = DEFAULT_MAX_RECORD_LENGTH;
+
+    /**
+     * @param length the max record length allowed for HemfText
+     */
+    public static void setMaxRecordLength(int length) {
+        MAX_RECORD_LENGTH = length;
+    }
+
+    /**
+     * @return the max record length allowed for HemfText
+     */
+    public static int getMaxRecordLength() {
+        return MAX_RECORD_LENGTH;
+    }
 
     public enum EmfGraphicsMode {
         GM_COMPATIBLE, GM_ADVANCED
index d0019cebf4c691800bde9635d440cfcd384cd14c..72f40b65f9ded100eef5c9b7aee032e5b9ae7141 100644 (file)
@@ -38,7 +38,22 @@ import org.apache.poi.util.LittleEndian;
 public final class HMEFDumper {
 
    //arbitrarily selected; may need to increase
-   private static final int MAX_RECORD_LENGTH = 1_000_000;
+   private static final int DEFAULT_MAX_RECORD_LENGTH = 1_000_000;
+   private static int MAX_RECORD_LENGTH = DEFAULT_MAX_RECORD_LENGTH;
+
+   /**
+    * @param length the max record length allowed for HMEFDumper
+    */
+   public static void setMaxRecordLength(int length) {
+      MAX_RECORD_LENGTH = length;
+   }
+
+   /**
+    * @return the max record length allowed for HMEFDumper
+    */
+   public static int getMaxRecordLength() {
+      return MAX_RECORD_LENGTH;
+   }
 
    public static void main(String[] args) throws Exception {
       if(args.length < 1) {
index 42f5ab66cdfefcfc3355336335a7851f0a69abca..44cc2aee7f291a68a804c1944e518250be18b40c 100644 (file)
@@ -35,14 +35,14 @@ public abstract class EscherPart extends HPBFPart {
     private static int MAX_RECORD_LENGTH = DEFAULT_MAX_RECORD_LENGTH;
 
     /**
-     * @param length the max record length allowed for CString
+     * @param length the max record length allowed for EscherPart
      */
     public static void setMaxRecordLength(int length) {
         MAX_RECORD_LENGTH = length;
     }
 
     /**
-     * @return the max record length allowed for CString
+     * @return the max record length allowed for EscherPart
      */
     public static int getMaxRecordLength() {
         return MAX_RECORD_LENGTH;
index 95e076e83bff82be8fa42f039faca127f0c07b61..e686ab0ca4b6a6d386b06149adf5b6f4a0808612 100644 (file)
@@ -34,9 +34,6 @@ import org.apache.poi.util.LittleEndian;
  */
 public final class AnimationInfoAtom extends RecordAtom {
 
-    //arbitrarily selected; may need to increase
-    private static final int MAX_RECORD_LENGTH = 100_000;
-
     /**
      * whether the animation plays in the reverse direction
      */
@@ -127,7 +124,7 @@ public final class AnimationInfoAtom extends RecordAtom {
         _header = Arrays.copyOfRange(source, start, start+8);
 
         // Grab the record data
-        _recdata = IOUtils.safelyClone(source,start+8, len-8, MAX_RECORD_LENGTH);
+        _recdata = IOUtils.safelyClone(source,start+8, len-8, getMaxRecordLength());
     }
 
     /**
index 07b9457b5ffe86c0d8480bfebe1d86fc6363580a..1d984d6e1952b85ce8bd298dd732bd7cd18e1832 100644 (file)
@@ -33,11 +33,7 @@ import org.apache.poi.util.LittleEndian;
  * An atomic record containing information about a comment.
  */
 
-public final class Comment2000Atom extends RecordAtom
-{
-
-    //arbitrarily selected; may need to increase
-    private static final int MAX_RECORD_LENGTH = 100_000;
+public final class Comment2000Atom extends RecordAtom {
 
     /**
      * Record header.
@@ -74,7 +70,7 @@ public final class Comment2000Atom extends RecordAtom
         _header = Arrays.copyOfRange(source, start, start+8);
 
         // Get the record data.
-        _data = IOUtils.safelyClone(source, start+8, len-8, MAX_RECORD_LENGTH);
+        _data = IOUtils.safelyClone(source, start+8, len-8, getMaxRecordLength());
     }
 
     /**
index a0765a43e3a344524accc3a487b294a4cdfb02f3..e73f7cbaf547e7dd43f999432db36bc54ee490f9 100644 (file)
@@ -33,9 +33,6 @@ import org.apache.poi.util.LittleEndian;
  */
 public final class ExHyperlinkAtom extends RecordAtom {
 
-    //arbitrarily selected; may need to increase
-    private static final int MAX_RECORD_LENGTH = 100_000;
-
     /**
      * Record header.
      */
@@ -72,7 +69,7 @@ public final class ExHyperlinkAtom extends RecordAtom {
         _header = Arrays.copyOfRange(source, start, start+8);
 
         // Get the record data.
-        _data = IOUtils.safelyClone(source, start+8, len-8, MAX_RECORD_LENGTH);
+        _data = IOUtils.safelyClone(source, start+8, len-8, getMaxRecordLength());
 
         // Must be at least 4 bytes long
         if(_data.length < 4) {
index eca4eb2704a1f19d09755d147801bac634c82fa5..552ec50ff08ee50f87fa1585696b8eaddb7ed777 100644 (file)
@@ -61,9 +61,6 @@ public final class HeadersFootersAtom extends RecordAtom {
         CHINESE3
     }
 
-    //arbitrarily selected; may need to increase
-    private static final int MAX_RECORD_LENGTH = 100_000;
-
     /**
      * A bit that specifies whether the date is displayed in the footer.
      * @see #getMask()
@@ -144,7 +141,7 @@ public final class HeadersFootersAtom extends RecordAtom {
         _header = Arrays.copyOfRange(source, start, start+8);
 
         // Grab the record data
-        _recdata = IOUtils.safelyClone(source, start+8, len-8, MAX_RECORD_LENGTH);
+        _recdata = IOUtils.safelyClone(source, start+8, len-8, getMaxRecordLength());
     }
 
     /**
index fbe51f35ebe83bfa57e53812ec81230c77c04151..fe48a9395fa6a176585ac057af2f424b8ace4fc8 100644 (file)
@@ -36,9 +36,6 @@ import org.apache.poi.util.LittleEndian;
  */
 public class InteractiveInfoAtom extends RecordAtom {
 
-    //arbitrarily selected; may need to increase
-    private static final int MAX_RECORD_LENGTH = 100_000;
-
     public enum Action {
         NONE,
         MACRO,
@@ -154,7 +151,7 @@ public class InteractiveInfoAtom extends RecordAtom {
         _header = Arrays.copyOfRange(source, start, start+8);
 
         // Get the record data.
-        _data = IOUtils.safelyClone(source, start+8, len-8, MAX_RECORD_LENGTH);
+        _data = IOUtils.safelyClone(source, start+8, len-8, getMaxRecordLength());
 
         // Must be at least 16 bytes long
         if(_data.length < 16) {
index 92772e141305a6ec9e8d6dc52ab4960894e762ed..db3482f0aad041346224830535b34bfbd57d6224 100644 (file)
@@ -45,11 +45,7 @@ import org.apache.poi.util.LittleEndianConsts;
  *  (via CurrentUserAtom and UserEditAtom) pointing to the new slide location
  */
 
-public final class PersistPtrHolder extends PositionDependentRecordAtom
-{
-
-    //arbitrarily selected; may need to increase
-    private static final int MAX_RECORD_LENGTH = 100_000;
+public final class PersistPtrHolder extends PositionDependentRecordAtom {
 
     private final byte[] _header;
     private byte[] _ptrData; // Will need to update this once we allow updates to _slideLocations
@@ -113,7 +109,7 @@ public final class PersistPtrHolder extends PositionDependentRecordAtom
         //   count * 32 bit offsets
         // Repeat as many times as you have data
         _slideLocations = new HashMap<>();
-        _ptrData = IOUtils.safelyClone(source, start+8, len-8, MAX_RECORD_LENGTH);
+        _ptrData = IOUtils.safelyClone(source, start+8, len-8, RecordAtom.getMaxRecordLength());
 
         int pos = 0;
         while(pos < _ptrData.length) {
index c4026720e4f1c3468ef597d8da54223981f063d6..cd1e77901ef8cfce00b302e32c748e41d59eda29 100644 (file)
@@ -28,14 +28,14 @@ public abstract class RecordAtom extends Record {
     private static int MAX_RECORD_LENGTH = DEFAULT_MAX_RECORD_LENGTH;
 
     /**
-     * @param length the max record length allowed for CString
+     * @param length the max record length allowed for RecordAtom
      */
     public static void setMaxRecordLength(int length) {
         MAX_RECORD_LENGTH = length;
     }
 
     /**
-     * @return the max record length allowed for CString
+     * @return the max record length allowed for RecordAtom
      */
     public static int getMaxRecordLength() {
         return MAX_RECORD_LENGTH;
index a9b083b236da98bc82ff543c20894c6ec251ccaf..d9e18a30d0df3f50e1743b7a812eb3412bde1ff7 100644 (file)
@@ -42,9 +42,6 @@ import org.apache.poi.util.LittleEndianOutputStream;
  */
 public final class TextRulerAtom extends RecordAtom {
 
-    //arbitrarily selected; may need to increase
-    private static final int MAX_RECORD_LENGTH = 100_000;
-
     private static final BitField DEFAULT_TAB_SIZE = getInstance(0x0001);
     private static final BitField C_LEVELS = getInstance(0x0002);
     private static final BitField TAB_STOPS = getInstance(0x0004);
@@ -87,7 +84,7 @@ public final class TextRulerAtom extends RecordAtom {
      * @param len the length of the slice in the byte array.
      */
     TextRulerAtom(final byte[] source, final int start, final int len) {
-        final LittleEndianByteArrayInputStream leis = new LittleEndianByteArrayInputStream(source, start, Math.min(len, MAX_RECORD_LENGTH));
+        final LittleEndianByteArrayInputStream leis = new LittleEndianByteArrayInputStream(source, start, Math.min(len, getMaxRecordLength()));
 
 
         try {
index da2a40ffba84f23f41c11c8a81735a66d945a3f7..aa71d41540987c5b120ba40c6bb7f16a2f0478d3 100644 (file)
@@ -38,9 +38,6 @@ import org.apache.poi.util.LittleEndianByteArrayInputStream;
  */
 public final class TextSpecInfoAtom extends RecordAtom {
 
-    //arbitrarily selected; may need to increase
-    private static final int MAX_RECORD_LENGTH = 100_000;
-
     private static final long _type = RecordTypes.TextSpecInfoAtom.typeID;
 
     /**
@@ -75,7 +72,7 @@ public final class TextSpecInfoAtom extends RecordAtom {
         _header = Arrays.copyOfRange(source, start, start+8);
 
         // Get the record data.
-        _data = IOUtils.safelyClone(source, start+8, len-8, MAX_RECORD_LENGTH);
+        _data = IOUtils.safelyClone(source, start+8, len-8, getMaxRecordLength());
     }
     /**
      * Gets the record type.
index ee419faf310e1d81de9cc58077a58d2bb8e5ccb0..ca94a6acfdba50d149b0e5c77ba3344667feccc9 100644 (file)
@@ -54,8 +54,6 @@ import org.apache.poi.util.LittleEndianOutputStream;
  */
 public final class TxMasterStyleAtom extends RecordAtom {
     private static final Logger LOG = LogManager.getLogger(TxMasterStyleAtom.class);
-    //arbitrarily selected; may need to increase
-    private static final int MAX_RECORD_LENGTH = 100_000;
 
     /**
      * Maximum number of indentation levels allowed in PowerPoint documents
@@ -73,7 +71,7 @@ public final class TxMasterStyleAtom extends RecordAtom {
     protected TxMasterStyleAtom(byte[] source, int start, int len) {
         _header = Arrays.copyOfRange(source, start, start+8);
 
-        _data = IOUtils.safelyClone(source, start+8, len-8, MAX_RECORD_LENGTH);
+        _data = IOUtils.safelyClone(source, start+8, len-8, getMaxRecordLength());
 
         //read available styles
         try {
index 6571c650af172bb81e5f4a7f4e3deb6371119ab6..e103c3367b8fccb90616d99b49cbf9d4390e49ca 100644 (file)
@@ -83,7 +83,8 @@ public final class HWPFDocument extends HWPFDocumentCore {
     /*package*/ static final String PROPERTY_PRESERVE_BIN_TABLES = "org.apache.poi.hwpf.preserveBinTables";
     private static final String PROPERTY_PRESERVE_TEXT_TABLE = "org.apache.poi.hwpf.preserveTextTable";
     //arbitrarily selected; may need to increase
-    private static final int MAX_RECORD_LENGTH = 1_000_000;
+    private static final int DEFAULT_MAX_RECORD_LENGTH = 100_000;
+    private static int MAX_RECORD_LENGTH = DEFAULT_MAX_RECORD_LENGTH;
 
     private static final String STREAM_DATA = "Data";
 
@@ -193,6 +194,20 @@ public final class HWPFDocument extends HWPFDocumentCore {
      */
     private Fields _fields;
 
+    /**
+     * @param length the max record length allowed for HWPFDocument
+     */
+    public static void setMaxRecordLength(int length) {
+        MAX_RECORD_LENGTH = length;
+    }
+
+    /**
+     * @return the max record length allowed for HWPFDocument
+     */
+    public static int getMaxRecordLength() {
+        return MAX_RECORD_LENGTH;
+    }
+
     /**
      * This constructor loads a Word document from an InputStream.
      *
index 91dfcf6c1f07e367f47331c93a654cbc82519126..50948b8869f960008142fe07f27ffe1e5f2a66bd 100644 (file)
@@ -21,6 +21,7 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
+import org.apache.poi.hwpf.HWPFDocument;
 import org.apache.poi.hwpf.sprm.SprmBuffer;
 import org.apache.poi.util.IOUtils;
 import org.apache.poi.util.Internal;
@@ -42,36 +43,16 @@ import org.apache.poi.util.RecordFormatException;
  * differently for CHP fkps and PAP fkps.
  */
 @Internal
-public final class CHPFormattedDiskPage extends FormattedDiskPage
-{
+public final class CHPFormattedDiskPage extends FormattedDiskPage {
     private static final int FC_SIZE = 4;
-    //arbitrarily selected; may need to increase
-    private static final int MAX_RECORD_LENGTH = 100_000;
-
 
     private ArrayList<CHPX> _chpxList = new ArrayList<>();
     private ArrayList<CHPX> _overFlow;
 
-
     public CHPFormattedDiskPage()
     {
     }
 
-    /**
-     * This constructs a CHPFormattedDiskPage from a raw fkp (512 byte array
-     * read from a Word file).
-     *
-     * @deprecated Use
-     *             {@link #CHPFormattedDiskPage(byte[], int, CharIndexTranslator)}
-     *             instead
-     */
-    @Deprecated
-    public CHPFormattedDiskPage( byte[] documentStream, int offset, int fcMin,
-            TextPieceTable tpt )
-    {
-        this( documentStream, offset, tpt );
-    }
-
     /**
      * This constructs a CHPFormattedDiskPage from a raw fkp (512 byte array
      * read from a Word file).
@@ -138,7 +119,7 @@ public final class CHPFormattedDiskPage extends FormattedDiskPage
 
         int size = LittleEndian.getUByte(_fkp, _offset + chpxOffset);
 
-        return IOUtils.safelyClone(_fkp, _offset + chpxOffset + 1, size, MAX_RECORD_LENGTH);
+        return IOUtils.safelyClone(_fkp, _offset + chpxOffset + 1, size, HWPFDocument.getMaxRecordLength());
     }
 
     protected byte[] toByteArray( CharIndexTranslator translator )
index 7dc6081cc5d4ac24000ff740185a351005211dd1..22eaadae524cbf53e44cee887c9106b898a796c4 100644 (file)
@@ -23,6 +23,7 @@ import java.nio.charset.Charset;
 import java.util.LinkedList;
 import java.util.List;
 
+import org.apache.poi.hwpf.HWPFDocument;
 import org.apache.poi.hwpf.model.io.HWPFFileSystem;
 import org.apache.poi.hwpf.sprm.SprmBuffer;
 import org.apache.poi.util.IOUtils;
@@ -34,9 +35,6 @@ import org.apache.poi.util.StringUtil;
 @Internal
 public class ComplexFileTable {
 
-    //arbitrarily selected; may need to increase
-    private static final int MAX_RECORD_LENGTH = 100_000;
-
     private static final byte GRPPRL_TYPE = 1;
     private static final byte TEXT_PIECE_TABLE_TYPE = 2;
 
@@ -57,7 +55,7 @@ public class ComplexFileTable {
             offset++;
             int size = LittleEndian.getShort(tableStream, offset);
             offset += LittleEndianConsts.SHORT_SIZE;
-            byte[] bs = IOUtils.safelyClone(tableStream, offset, size, MAX_RECORD_LENGTH);
+            byte[] bs = IOUtils.safelyClone(tableStream, offset, size, HWPFDocument.getMaxRecordLength());
             offset += size;
 
             SprmBuffer sprmBuffer = new SprmBuffer(bs, false, 0);
index 963c0f5942fc9c7916cbe4dc89242b62fc62c352..40ccd73cc5f466244d9ea05921b69f5950e8f819 100644 (file)
@@ -20,34 +20,16 @@ package org.apache.poi.hwpf.model;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 
+import org.apache.poi.hwpf.HWPFDocument;
 import org.apache.poi.hwpf.model.types.DOPAbstractType;
 import org.apache.poi.util.IOUtils;
 import org.apache.poi.util.Internal;
 
 @Internal
-public final class DocumentProperties extends DOPAbstractType
-{
-
-    //arbitrarily selected; may need to increase
-    private static final int DEFAULT_MAX_RECORD_LENGTH = 100_000;
-    private static int MAX_RECORD_LENGTH = DEFAULT_MAX_RECORD_LENGTH;
+public final class DocumentProperties extends DOPAbstractType {
 
     private byte[] _preserved;
 
-    /**
-     * @param length the max record length allowed for DocumentProperties
-     */
-    public static void setMaxRecordLength(int length) {
-        MAX_RECORD_LENGTH = length;
-    }
-
-    /**
-     * @return the max record length allowed for DocumentProperties
-     */
-    public static int getMaxRecordLength() {
-        return MAX_RECORD_LENGTH;
-    }
-
     /**
      * @deprecated Use {@link #DocumentProperties(byte[],int,int)} instead
      */
@@ -63,7 +45,8 @@ public final class DocumentProperties extends DOPAbstractType
         final int supportedSize = DOPAbstractType.getSize();
         if ( length != supportedSize )
         {
-            this._preserved = IOUtils.safelyClone( tableStream, offset + supportedSize, length - supportedSize, MAX_RECORD_LENGTH );
+            this._preserved = IOUtils.safelyClone( tableStream, offset + supportedSize,
+                    length - supportedSize, HWPFDocument.getMaxRecordLength());
         }
         else
         {
index 346f5aabf84f5b16b2a0e5448d2146bf63d99425..bea8b2e581082c9c95d90cf5e72a238b6ad3f13d 100644 (file)
@@ -19,6 +19,7 @@ package org.apache.poi.hwpf.model;
 
 import java.util.Arrays;
 
+import org.apache.poi.hwpf.HWPFDocument;
 import org.apache.poi.util.BitField;
 import org.apache.poi.util.BitFieldFactory;
 import org.apache.poi.util.IOUtils;
@@ -34,10 +35,6 @@ import org.apache.poi.util.LittleEndianConsts;
 @Internal
 public final class Ffn {
 
-    //arbitrarily selected; may need to increase
-    private static final int DEFAULT_MAX_RECORD_LENGTH = 100_000;
-    private static int MAX_RECORD_LENGTH = DEFAULT_MAX_RECORD_LENGTH;
-
     private int _cbFfnM1;//total length of FFN - 1.
     private byte _info;
     private static BitField _prq = BitFieldFactory.getInstance(0x0003);// pitch request
@@ -57,20 +54,6 @@ public final class Ffn {
     // extra facilitator members
     private int _xszFfnLength;
 
-    /**
-     * @param length the max record length allowed for Ffn
-     */
-    public static void setMaxRecordLength(int length) {
-      MAX_RECORD_LENGTH = length;
-    }
-  
-    /**
-     * @return the max record length allowed for Ffn
-     */
-    public static int getMaxRecordLength() {
-      return MAX_RECORD_LENGTH;
-    }
-
     public Ffn(byte[] buf, int offset) {
         int offsetTmp = offset;
 
@@ -155,7 +138,7 @@ public final class Ffn {
     // changed protected to public
     public byte[] toByteArray() {
         int offset = 0;
-        byte[] buf = IOUtils.safelyAllocate(this.getSize(), MAX_RECORD_LENGTH);
+        byte[] buf = IOUtils.safelyAllocate(this.getSize(), HWPFDocument.getMaxRecordLength());
 
         buf[offset] = (byte) _cbFfnM1;
         offset += LittleEndianConsts.BYTE_SIZE;
index 9c29edc297858c3a1d612ae901d7f899927530f4..a3b70865804ddeb8db8a4d51b58e1e675a97520c 100644 (file)
@@ -26,6 +26,7 @@ import java.util.Locale;
 
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
+import org.apache.poi.hwpf.HWPFDocument;
 import org.apache.poi.hwpf.model.types.FibBaseAbstractType;
 import org.apache.poi.hwpf.model.types.FibRgLw97AbstractType;
 import org.apache.poi.hwpf.model.types.FibRgW97AbstractType;
@@ -50,9 +51,6 @@ import static org.apache.logging.log4j.util.Unbox.box;
 @Internal
 public final class FileInformationBlock {
 
-    //arbitrarily selected; may need to increase
-    private static final int MAX_RECORD_LENGTH = 100_000;
-
     private static final Logger LOG = LogManager.getLogger(FileInformationBlock.class);
 
     private final FibBase _fibBase;
@@ -124,7 +122,7 @@ public final class FileInformationBlock {
 
             // first short is already read as _nFibNew
             final int fibRgCswNewLength = ( _cswNew - 1 ) * LittleEndianConsts.SHORT_SIZE;
-            _fibRgCswNew = IOUtils.safelyClone(mainDocument, offset, fibRgCswNewLength, MAX_RECORD_LENGTH);
+            _fibRgCswNew = IOUtils.safelyClone(mainDocument, offset, fibRgCswNewLength, HWPFDocument.getMaxRecordLength());
         }
         else
         {
index fb34604169a06dcd270fe3651d8687e532eb0a0f..59163a578ca6b3e9c4674ec8d76c9d77c155c7a7 100644 (file)
@@ -25,17 +25,14 @@ import org.apache.poi.ddf.EscherBlipRecord;
 import org.apache.poi.ddf.EscherContainerRecord;
 import org.apache.poi.ddf.EscherRecord;
 import org.apache.poi.ddf.EscherRecordTypes;
+import org.apache.poi.hwpf.HWPFDocument;
 import org.apache.poi.hwpf.model.types.PICFAbstractType;
 import org.apache.poi.util.IOUtils;
 import org.apache.poi.util.Internal;
 import org.apache.poi.util.LittleEndian;
 
 @Internal
-public class PICFAndOfficeArtData
-{
-
-    //arbitrarily selected; may need to increase
-    private static final int MAX_RECORD_LENGTH = 100_000;
+public class PICFAndOfficeArtData {
 
     /**
      * Can contain either a {@link EscherBlipRecord} or a {@link EscherBSERecord}.
@@ -65,7 +62,7 @@ public class PICFAndOfficeArtData
             short _cchPicName = LittleEndian.getUByte(dataStream, offset);
             offset += 1;
 
-            _stPicName = IOUtils.safelyClone(dataStream, offset, _cchPicName, MAX_RECORD_LENGTH);
+            _stPicName = IOUtils.safelyClone(dataStream, offset, _cchPicName, HWPFDocument.getMaxRecordLength());
             offset += _cchPicName;
         }
 
index 547960c185538362662e8d48f8d2405026864640..35e74bf10d5f122c903cc9ee62886d854099a12a 100644 (file)
@@ -24,6 +24,7 @@ import java.util.List;
 
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
+import org.apache.poi.hwpf.HWPFDocument;
 import org.apache.poi.hwpf.model.io.HWPFFileSystem;
 import org.apache.poi.util.IOUtils;
 import org.apache.poi.util.Internal;
@@ -31,11 +32,7 @@ import org.apache.poi.util.LittleEndian;
 import org.apache.poi.util.LittleEndianConsts;
 
 @Internal
-public class SectionTable
-{
-
-    //arbitrarily selected; may need to increase
-    private static final int MAX_RECORD_LENGTH = 100_000;
+public class SectionTable {
 
     private static final Logger LOG = LogManager.getLogger(SectionTable.class);
     private static final int SED_SIZE = 12;
@@ -82,7 +79,7 @@ public class SectionTable
                 // The first short at the offset is the size of the grpprl.
                 int sepxSize = LittleEndian.getShort(documentStream, fileOffset);
                 fileOffset += LittleEndianConsts.SHORT_SIZE;
-                byte[] buf = IOUtils.safelyClone(documentStream, fileOffset, sepxSize, MAX_RECORD_LENGTH);
+                byte[] buf = IOUtils.safelyClone(documentStream, fileOffset, sepxSize, HWPFDocument.getMaxRecordLength());
                 _sections.add(new SEPX(sed, startAt, endAt, buf));
             }
         }
index 438e778ab515b0d480b1fb79ccaffeeafa4e55c6..028b943d0ae7577c19f08d4b20ce352134f4f685 100644 (file)
Binary files a/poi/src/test/java9/module-info.class and b/poi/src/test/java9/module-info.class differ