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

pjfanning pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/poi.git


The following commit(s) were added to refs/heads/trunk by this push:
     new ffd05bbaae more allocation check changes
ffd05bbaae is described below

commit ffd05bbaae41cde87f42cf187fe50c8d9a0c2bf5
Author: PJ Fanning <[email protected]>
AuthorDate: Thu Jun 4 22:16:36 2026 +0100

    more allocation check changes
    
    more
---
 .../main/java/org/apache/poi/hdgf/chunks/ChunkFactory.java |  3 ++-
 .../java/org/apache/poi/hdgf/pointers/PointerFactory.java  |  5 +++--
 .../org/apache/poi/hdgf/streams/CompressedStreamStore.java |  3 ++-
 .../main/java/org/apache/poi/hdgf/streams/StreamStore.java |  6 ++++--
 .../src/main/java/org/apache/poi/hmef/CompressedRTF.java   |  6 ++++--
 .../java/org/apache/poi/hmef/attribute/MAPIAttribute.java  |  9 +++++----
 .../org/apache/poi/hmef/attribute/MAPIRtfAttribute.java    | 14 ++++++++++++--
 .../java/org/apache/poi/hmef/attribute/TNEFAttribute.java  |  2 +-
 .../src/main/java/org/apache/poi/hmef/dev/HMEFDumper.java  |  3 ++-
 .../main/java/org/apache/poi/hpbf/model/EscherPart.java    |  2 +-
 .../main/java/org/apache/poi/hpbf/model/QuillContents.java |  6 ++++--
 .../java/org/apache/poi/hpbf/model/qcbits/QCPLCBit.java    |  4 ++--
 .../java/org/apache/poi/hpbf/model/qcbits/QCTextBit.java   |  3 ++-
 .../org/apache/poi/hsmf/datatypes/PropertiesChunk.java     |  3 ++-
 .../java/org/apache/poi/hwmf/record/HwmfBitmapDib.java     |  6 ++++--
 .../src/main/java/org/apache/poi/hwmf/record/HwmfText.java |  9 ++++++---
 .../java/org/apache/poi/hwmf/record/HwmfWindowing.java     |  3 ++-
 17 files changed, 58 insertions(+), 29 deletions(-)

diff --git 
a/poi-scratchpad/src/main/java/org/apache/poi/hdgf/chunks/ChunkFactory.java 
b/poi-scratchpad/src/main/java/org/apache/poi/hdgf/chunks/ChunkFactory.java
index 04e67c2a20..a7bfba11ec 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hdgf/chunks/ChunkFactory.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hdgf/chunks/ChunkFactory.java
@@ -193,7 +193,8 @@ public final class ChunkFactory {
         }
 
         // Now, create the chunk
-        byte[] contents = IOUtils.safelyClone(data, 
offset+header.getSizeInBytes(), header.getLength(), MAX_RECORD_LENGTH);
+        byte[] contents = IOUtils.safelyClone(data, 
offset+header.getSizeInBytes(), header.getLength(),
+                MAX_RECORD_LENGTH, "ChunkFactory.setMaxRecordLength()");
         Chunk chunk = new Chunk(header, trailer, separator, contents);
 
         // Feed in the stuff from  chunks_parse_cmds.tbl
diff --git 
a/poi-scratchpad/src/main/java/org/apache/poi/hdgf/pointers/PointerFactory.java 
b/poi-scratchpad/src/main/java/org/apache/poi/hdgf/pointers/PointerFactory.java
index 17fc3ebe5e..18448751c6 100644
--- 
a/poi-scratchpad/src/main/java/org/apache/poi/hdgf/pointers/PointerFactory.java
+++ 
b/poi-scratchpad/src/main/java/org/apache/poi/hdgf/pointers/PointerFactory.java
@@ -18,6 +18,7 @@ package org.apache.poi.hdgf.pointers;
 
 import org.apache.poi.hdgf.exceptions.OldVisioFormatException;
 import org.apache.poi.hdgf.streams.PointerContainingStream;
+import org.apache.poi.util.ArrayUtil;
 import org.apache.poi.util.IOUtils;
 import org.apache.poi.util.LittleEndian;
 import org.apache.poi.util.RecordFormatException;
@@ -54,7 +55,7 @@ public final class PointerFactory {
             final long v6Offset = LittleEndian.getUInt(data, offset+8);
             final long v6Length = LittleEndian.getUInt(data, offset+12);
             checkPointerOffset(v6Offset);
-            IOUtils.safelyAllocateCheck(v6Length, Integer.MAX_VALUE);
+            ArrayUtil.strictAllocateCheck(v6Length, Integer.MAX_VALUE);
             p.setOffset((int)v6Offset);
             p.setLength((int)v6Length);
             p.setFormat(LittleEndian.getShort(data, offset+16));
@@ -101,7 +102,7 @@ public final class PointerFactory {
             throw new IllegalArgumentException("Cannot create container 
pointers with negative count: " + numPointers);
         }
 
-        IOUtils.safelyAllocateCheck(numPointers, MAX_NUMBER_OF_POINTERS);
+        ArrayUtil.strictAllocateCheck(numPointers, MAX_NUMBER_OF_POINTERS);
 
         // Create
         int pos = numPointersOffset + skip;
diff --git 
a/poi-scratchpad/src/main/java/org/apache/poi/hdgf/streams/CompressedStreamStore.java
 
b/poi-scratchpad/src/main/java/org/apache/poi/hdgf/streams/CompressedStreamStore.java
index d4ca5c8bc9..743e3f3a27 100644
--- 
a/poi-scratchpad/src/main/java/org/apache/poi/hdgf/streams/CompressedStreamStore.java
+++ 
b/poi-scratchpad/src/main/java/org/apache/poi/hdgf/streams/CompressedStreamStore.java
@@ -65,7 +65,8 @@ public final class CompressedStreamStore extends StreamStore {
      */
     CompressedStreamStore(byte[] data, int offset, int length) throws 
IOException {
         this(decompress(data,offset,length));
-        compressedContents = IOUtils.safelyClone(data, offset, length, 
MAX_RECORD_LENGTH);
+        compressedContents = IOUtils.safelyClone(data, offset, length, 
MAX_RECORD_LENGTH,
+                "CompressedStreamStore.setMaxRecordLength()");
     }
     /**
      * Handles passing the de-compressed data onto our superclass.
diff --git 
a/poi-scratchpad/src/main/java/org/apache/poi/hdgf/streams/StreamStore.java 
b/poi-scratchpad/src/main/java/org/apache/poi/hdgf/streams/StreamStore.java
index 7d31e6abec..2deea44e52 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hdgf/streams/StreamStore.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hdgf/streams/StreamStore.java
@@ -49,11 +49,13 @@ public class StreamStore { // TODO - instantiable superclass
      * Creates a new, non compressed Stream Store
      */
     protected StreamStore(byte[] data, int offset, int length) {
-        contents = IOUtils.safelyClone(data, offset, length, 
MAX_RECORD_LENGTH);
+        contents = IOUtils.safelyClone(data, offset, length, MAX_RECORD_LENGTH,
+                "StreamStore.setMaxRecordLength()");
     }
 
     protected void prependContentsWith(byte[] b) {
-        byte[] newContents = IOUtils.safelyAllocate(contents.length + 
(long)b.length, MAX_RECORD_LENGTH);
+        byte[] newContents = IOUtils.safelyAllocate(contents.length + 
(long)b.length,
+                MAX_RECORD_LENGTH, "StreamStore.setMaxRecordLength()");
         System.arraycopy(b, 0, newContents, 0, b.length);
         System.arraycopy(contents, 0, newContents, b.length, contents.length);
         contents = newContents;
diff --git 
a/poi-scratchpad/src/main/java/org/apache/poi/hmef/CompressedRTF.java 
b/poi-scratchpad/src/main/java/org/apache/poi/hmef/CompressedRTF.java
index 925ace90be..740989639e 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hmef/CompressedRTF.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hmef/CompressedRTF.java
@@ -24,6 +24,7 @@ import java.nio.charset.StandardCharsets;
 
 import org.apache.commons.io.input.BoundedInputStream;
 import org.apache.commons.io.output.ThresholdingOutputStream;
+import org.apache.poi.util.ArrayUtil;
 import org.apache.poi.util.IOUtils;
 import org.apache.poi.util.LZWDecompresser;
 import org.apache.poi.util.LittleEndian;
@@ -106,7 +107,7 @@ public final class CompressedRTF extends LZWDecompresser {
       /* int dataCRC = */ LittleEndian.readInt(src);
 
       // TODO - Handle CRC checking on the output side
-      IOUtils.safelyAllocateCheck(decompressedSize, MAX_RECORD_LENGTH);
+      ArrayUtil.safelyAllocateCheck(decompressedSize, MAX_RECORD_LENGTH, 
"CompressedRTF.setMaxRecordLength()");
 
       // Do we need to do anything?
       if(compressionType == UNCOMPRESSED_SIGNATURE_INT) {
@@ -166,7 +167,8 @@ public final class CompressedRTF extends LZWDecompresser {
 
    private void copyCompressedPayload(InputStream src, OutputStream res) 
throws IOException {
       long remaining = getCompressedSize();
-      byte[] buffer = IOUtils.safelyAllocate(Math.min(8192L, remaining), 
MAX_RECORD_LENGTH);
+      byte[] buffer = IOUtils.safelyAllocate(Math.min(8192L, remaining),
+              MAX_RECORD_LENGTH, "CompressedRTF.setMaxRecordLength()");
       while (remaining > 0) {
          int read = src.read(buffer, 0, 
Math.toIntExact(Math.min(buffer.length, remaining)));
          if (read < 0) {
diff --git 
a/poi-scratchpad/src/main/java/org/apache/poi/hmef/attribute/MAPIAttribute.java 
b/poi-scratchpad/src/main/java/org/apache/poi/hmef/attribute/MAPIAttribute.java
index de08c4fc49..eac941d29c 100644
--- 
a/poi-scratchpad/src/main/java/org/apache/poi/hmef/attribute/MAPIAttribute.java
+++ 
b/poi-scratchpad/src/main/java/org/apache/poi/hmef/attribute/MAPIAttribute.java
@@ -29,6 +29,7 @@ import org.apache.poi.hmef.HMEFMessage;
 import org.apache.poi.hsmf.datatypes.MAPIProperty;
 import org.apache.poi.hsmf.datatypes.Types;
 import org.apache.poi.hsmf.datatypes.Types.MAPIType;
+import org.apache.poi.util.ArrayUtil;
 import org.apache.poi.util.HexDump;
 import org.apache.poi.util.IOUtils;
 import org.apache.poi.util.LittleEndian;
@@ -42,7 +43,7 @@ public class MAPIAttribute {
 
    //arbitrarily selected; may need to increase
    private static final int DEFAULT_MAX_RECORD_LENGTH = 1_000_000;
-   private static int MAX_RECORD_LENGTH = 1_000_000;
+   private static int MAX_RECORD_LENGTH = DEFAULT_MAX_RECORD_LENGTH;
    private static int MAX_RECORD_COUNT = 10_000;
 
    private final MAPIProperty property;
@@ -165,7 +166,7 @@ public class MAPIAttribute {
                } else {
                   // Custom name was stored
                   int mplen = LittleEndian.readInt(inp);
-                  byte[] mpdata = IOUtils.safelyAllocate(mplen, 
MAX_RECORD_LENGTH);
+                  byte[] mpdata = IOUtils.safelyAllocate(mplen, 
MAX_RECORD_LENGTH, "MAPIAttribute.setMaxRecordLength()");
                   if (IOUtils.readFully(inp, mpdata) < 0) {
                      throw new IOException("Not enough data to read " + mplen 
+ " bytes for attribute name");
                   }
@@ -184,7 +185,7 @@ public class MAPIAttribute {
             int values = 1;
             if(isMV || isVL) {
                values = LittleEndian.readInt(inp);
-               IOUtils.safelyAllocateCheck(values, MAX_RECORD_COUNT);
+               ArrayUtil.strictAllocateCheck(values, MAX_RECORD_COUNT);
             }
 
             if (type == Types.NULL && values > 1) {
@@ -193,7 +194,7 @@ public class MAPIAttribute {
 
             for(int j=0; j<values; j++) {
                int len = getLength(type, inp);
-               byte[] data = IOUtils.safelyAllocate(len, MAX_RECORD_LENGTH);
+               byte[] data = IOUtils.safelyAllocate(len, MAX_RECORD_LENGTH, 
"MAPIAttribute.setMaxRecordLength()");
                if (IOUtils.readFully(inp, data) < 0) {
                   throw new IOException("Not enough data to read " + len + " 
bytes of attribute value");
                }
diff --git 
a/poi-scratchpad/src/main/java/org/apache/poi/hmef/attribute/MAPIRtfAttribute.java
 
b/poi-scratchpad/src/main/java/org/apache/poi/hmef/attribute/MAPIRtfAttribute.java
index 6683beb878..1180b78381 100644
--- 
a/poi-scratchpad/src/main/java/org/apache/poi/hmef/attribute/MAPIRtfAttribute.java
+++ 
b/poi-scratchpad/src/main/java/org/apache/poi/hmef/attribute/MAPIRtfAttribute.java
@@ -35,7 +35,16 @@ import org.apache.poi.util.StringUtil;
 public final class MAPIRtfAttribute extends MAPIAttribute {
 
    //arbitrarily selected; may need to increase
-   private static final int MAX_RECORD_LENGTH = 50_000_000;
+   private static final int DEFAULT_MAX_RECORD_LENGTH = 50_000_000;
+   private static int MAX_RECORD_LENGTH = DEFAULT_MAX_RECORD_LENGTH;
+
+   public static void setMaxRecordLength(int length) {
+      MAX_RECORD_LENGTH = length;
+   }
+
+   public static int getMaxRecordLength() {
+      return MAX_RECORD_LENGTH;
+   }
 
    private final byte[] decompressed;
    private final String data;
@@ -51,7 +60,8 @@ public final class MAPIRtfAttribute extends MAPIAttribute {
       }
 
       if(tmp.length > rtf.getDeCompressedSize()) {
-         this.decompressed = IOUtils.safelyClone(tmp, 0, 
rtf.getDeCompressedSize(), MAX_RECORD_LENGTH);
+         this.decompressed = IOUtils.safelyClone(tmp, 0, 
rtf.getDeCompressedSize(),
+                 MAX_RECORD_LENGTH, "MAPIRtfAttribute.setMaxRecordLength()");
       } else {
          this.decompressed = tmp;
       }
diff --git 
a/poi-scratchpad/src/main/java/org/apache/poi/hmef/attribute/TNEFAttribute.java 
b/poi-scratchpad/src/main/java/org/apache/poi/hmef/attribute/TNEFAttribute.java
index 479cb8a56f..ef64647bfe 100644
--- 
a/poi-scratchpad/src/main/java/org/apache/poi/hmef/attribute/TNEFAttribute.java
+++ 
b/poi-scratchpad/src/main/java/org/apache/poi/hmef/attribute/TNEFAttribute.java
@@ -66,7 +66,7 @@ public class TNEFAttribute {
       int length = LittleEndian.readInt(inp);
       
       property = TNEFProperty.getBest(id, type);
-      data = IOUtils.safelyAllocate(length, MAX_RECORD_LENGTH);
+      data = IOUtils.safelyAllocate(length, MAX_RECORD_LENGTH, 
"TNEFAttribute.setMaxRecordLength()");
       IOUtils.readFully(inp, data);
       
       checksum = LittleEndian.readUShort(inp);
diff --git 
a/poi-scratchpad/src/main/java/org/apache/poi/hmef/dev/HMEFDumper.java 
b/poi-scratchpad/src/main/java/org/apache/poi/hmef/dev/HMEFDumper.java
index e3cbeb3b9a..6ce5fc665b 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hmef/dev/HMEFDumper.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hmef/dev/HMEFDumper.java
@@ -156,7 +156,8 @@ public final class HMEFDumper {
                   thisLen = len - offset;
                }
 
-               byte[] data = IOUtils.safelyClone(attr.getData(), offset, 
thisLen, MAX_RECORD_LENGTH);
+               byte[] data = IOUtils.safelyClone(attr.getData(), offset, 
thisLen, MAX_RECORD_LENGTH,
+                       "HMEFDumper.setMaxRecordLength()");
 
                System.out.print(
                      indent + HexDump.dump(data, 0, 0)
diff --git 
a/poi-scratchpad/src/main/java/org/apache/poi/hpbf/model/EscherPart.java 
b/poi-scratchpad/src/main/java/org/apache/poi/hpbf/model/EscherPart.java
index cdda185953..669db94639 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hpbf/model/EscherPart.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hpbf/model/EscherPart.java
@@ -89,7 +89,7 @@ public abstract class EscherPart extends HPBFPart {
             size += escherRecord.getRecordSize();
         }
 
-        byte[] data = IOUtils.safelyAllocate(size, MAX_RECORD_LENGTH);
+        byte[] data = IOUtils.safelyAllocate(size, MAX_RECORD_LENGTH, 
"EscherPart.setMaxRecordLength()");
         size = 0;
         for (EscherRecord record : records) {
             int thisSize =
diff --git 
a/poi-scratchpad/src/main/java/org/apache/poi/hpbf/model/QuillContents.java 
b/poi-scratchpad/src/main/java/org/apache/poi/hpbf/model/QuillContents.java
index ee7aac0aee..5e4d133127 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hpbf/model/QuillContents.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hpbf/model/QuillContents.java
@@ -78,11 +78,13 @@ public final class QuillContents extends HPBFPart {
                     throw new RecordFormatException(
                             "QuillContents bit offset " + fromU + " exceeds 
Integer.MAX_VALUE");
                 }
-                IOUtils.safelyAllocateCheck(lenU, 
EscherPart.getMaxRecordLength());
+                IOUtils.safelyAllocateCheck(lenU, 
EscherPart.getMaxRecordLength(),
+                        "EscherPart.setMaxRecordLength()");
                 int from = Math.toIntExact(fromU);
                 int len  = Math.toIntExact(lenU);
 
-                byte[] bitData = IOUtils.safelyClone(data, from, len, 
EscherPart.getMaxRecordLength());
+                byte[] bitData = IOUtils.safelyClone(data, from, len, 
EscherPart.getMaxRecordLength(),
+                        "EscherPart.setMaxRecordLength()");
 
                 // Create
                 if(bitType.equals("TEXT")) {
diff --git 
a/poi-scratchpad/src/main/java/org/apache/poi/hpbf/model/qcbits/QCPLCBit.java 
b/poi-scratchpad/src/main/java/org/apache/poi/hpbf/model/qcbits/QCPLCBit.java
index af5a138e4f..5d448575a6 100644
--- 
a/poi-scratchpad/src/main/java/org/apache/poi/hpbf/model/qcbits/QCPLCBit.java
+++ 
b/poi-scratchpad/src/main/java/org/apache/poi/hpbf/model/qcbits/QCPLCBit.java
@@ -17,7 +17,7 @@
 
 package org.apache.poi.hpbf.model.qcbits;
 
-import org.apache.poi.util.IOUtils;
+import org.apache.poi.util.ArrayUtil;
 import org.apache.poi.util.LittleEndian;
 import org.apache.poi.util.StringUtil;
 
@@ -56,7 +56,7 @@ public abstract class QCPLCBit extends QCBit {
         typeOfPLCS = (int)LittleEndian.getUInt(data, 4);
 
         // Init the arrays that we can
-        IOUtils.safelyAllocateCheck(numberOfPLCs, MAX_NUMBER_OF_PLCS);
+        ArrayUtil.strictAllocateCheck(numberOfPLCs, MAX_NUMBER_OF_PLCS);
         plcValA = new long[numberOfPLCs];
         plcValB = new long[numberOfPLCs];
     }
diff --git 
a/poi-scratchpad/src/main/java/org/apache/poi/hpbf/model/qcbits/QCTextBit.java 
b/poi-scratchpad/src/main/java/org/apache/poi/hpbf/model/qcbits/QCTextBit.java
index a8074ef085..f988de3f38 100644
--- 
a/poi-scratchpad/src/main/java/org/apache/poi/hpbf/model/qcbits/QCTextBit.java
+++ 
b/poi-scratchpad/src/main/java/org/apache/poi/hpbf/model/qcbits/QCTextBit.java
@@ -56,7 +56,8 @@ public final class QCTextBit extends QCBit {
     }
 
     public void setText(String text) {
-        byte[] data = IOUtils.safelyAllocate(text.length() * 2L, 
MAX_RECORD_LENGTH);
+        byte[] data = IOUtils.safelyAllocate(text.length() * 2L, 
MAX_RECORD_LENGTH,
+                "QCTextBit.setMaxRecordLength()");
         StringUtil.putUnicodeLE(text, data, 0);
         setData(data);
     }
diff --git 
a/poi-scratchpad/src/main/java/org/apache/poi/hsmf/datatypes/PropertiesChunk.java
 
b/poi-scratchpad/src/main/java/org/apache/poi/hsmf/datatypes/PropertiesChunk.java
index 7b037f3e5b..a2f187ea80 100644
--- 
a/poi-scratchpad/src/main/java/org/apache/poi/hsmf/datatypes/PropertiesChunk.java
+++ 
b/poi-scratchpad/src/main/java/org/apache/poi/hsmf/datatypes/PropertiesChunk.java
@@ -267,7 +267,8 @@ public abstract class PropertiesChunk extends Chunk {
                 }
 
                 // Grab the data block
-                byte[] data = IOUtils.safelyAllocate(length, 
MAX_RECORD_LENGTH);
+                byte[] data = IOUtils.safelyAllocate(length, MAX_RECORD_LENGTH,
+                        "PropertiesChunk.setMaxRecordLength()");
                 IOUtils.readFully(value, data);
 
                 // Skip over any padding
diff --git 
a/poi-scratchpad/src/main/java/org/apache/poi/hwmf/record/HwmfBitmapDib.java 
b/poi-scratchpad/src/main/java/org/apache/poi/hwmf/record/HwmfBitmapDib.java
index 4669d6ed97..9e92e99f74 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hwmf/record/HwmfBitmapDib.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hwmf/record/HwmfBitmapDib.java
@@ -262,14 +262,16 @@ public class HwmfBitmapDib implements GenericRecord {
             headerCompression == Compression.BI_CMYK) {
             int fileSize = Math.toIntExact(
                     Math.min(introSize + bodySize, recordSize));
-            imageData = IOUtils.safelyAllocate(fileSize, 
HwmfPicture.getMaxRecordLength());
+            imageData = IOUtils.safelyAllocate(fileSize, 
HwmfPicture.getMaxRecordLength(),
+                    "HwmfPicture.setMaxRecordLength()");
             leis.readFully(imageData, 0, introSize);
             leis.skipFully(recordSize-fileSize);
             // emfs are sometimes truncated, read as much as possible
             int readBytes = leis.read(imageData, introSize, 
fileSize-introSize);
             return introSize+(recordSize-fileSize)+readBytes;
         } else {
-            imageData = IOUtils.safelyAllocate(recordSize, 
HwmfPicture.getMaxRecordLength());
+            imageData = IOUtils.safelyAllocate(recordSize, 
HwmfPicture.getMaxRecordLength(),
+                    "HwmfPicture.setMaxRecordLength()");
             leis.readFully(imageData);
             return recordSize;
         }
diff --git 
a/poi-scratchpad/src/main/java/org/apache/poi/hwmf/record/HwmfText.java 
b/poi-scratchpad/src/main/java/org/apache/poi/hwmf/record/HwmfText.java
index b78950b5cb..8bdd5ed9ca 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hwmf/record/HwmfText.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hwmf/record/HwmfText.java
@@ -216,7 +216,8 @@ public class HwmfText {
         @Override
         public int init(LittleEndianInputStream leis, long recordSize, int 
recordFunction) throws IOException {
             stringLength = leis.readShort();
-            rawTextBytes = 
IOUtils.safelyAllocate(stringLength+(long)(stringLength&1), MAX_RECORD_LENGTH);
+            rawTextBytes = 
IOUtils.safelyAllocate(stringLength+(long)(stringLength&1),
+                    MAX_RECORD_LENGTH, "HwmfText.setMaxRecordLength()");
             leis.readFully(rawTextBytes);
             // A 16-bit signed integer that defines the vertical (y-axis) 
coordinate, in logical
             // units, of the point where drawing is to start.
@@ -245,7 +246,8 @@ public class HwmfText {
          * This does not include the extra optional padding on the byte array.
          */
         private byte[] getTextBytes() {
-            return IOUtils.safelyClone(rawTextBytes, 0, stringLength, 
MAX_RECORD_LENGTH);
+            return IOUtils.safelyClone(rawTextBytes, 0, stringLength, 
MAX_RECORD_LENGTH,
+                    "HwmfText.setMaxRecordLength()");
         }
 
         @Override
@@ -440,7 +442,8 @@ public class HwmfText {
                 size += readRectS(leis, bounds);
             }
 
-            rawTextBytes = 
IOUtils.safelyAllocate(stringLength+(long)(stringLength&1), MAX_RECORD_LENGTH);
+            rawTextBytes = 
IOUtils.safelyAllocate(stringLength+(long)(stringLength&1), MAX_RECORD_LENGTH,
+                    "HwmfText.setMaxRecordLength()");
             leis.readFully(rawTextBytes);
             size += rawTextBytes.length;
 
diff --git 
a/poi-scratchpad/src/main/java/org/apache/poi/hwmf/record/HwmfWindowing.java 
b/poi-scratchpad/src/main/java/org/apache/poi/hwmf/record/HwmfWindowing.java
index 3d7ba8ee80..6a5d2176c9 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hwmf/record/HwmfWindowing.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hwmf/record/HwmfWindowing.java
@@ -743,7 +743,8 @@ public class HwmfWindowing {
             bounds.setRect(left, top, right-left, bottom-top);
 
             int size = 
9*LittleEndianConsts.SHORT_SIZE+LittleEndianConsts.INT_SIZE;
-            IOUtils.safelyAllocateCheck(scanCount, 
HwmfPicture.getMaxRecordLength());
+            IOUtils.safelyAllocateCheck(scanCount, 
HwmfPicture.getMaxRecordLength(),
+                    "HwmfPicture.setMaxRecordLength()");
             scanObjects = new WmfScanObject[scanCount];
             for (int i=0; i<scanCount; i++) {
                 size += (scanObjects[i] = new WmfScanObject()).init(leis);


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

Reply via email to