make HPSF limit more configuarble

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1900402 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
PJ Fanning 2022-04-29 21:47:45 +00:00
parent bc30e1a6f5
commit fcb4d09480
1 changed files with 10 additions and 2 deletions

View File

@ -22,8 +22,16 @@ import org.apache.poi.util.LittleEndianByteArrayInputStream;
@Internal
public class Array {
private static final int DEFAULT_MAX_NUMBER_OF_ARRAY_SCALARS = 100_000;
private static int MAX_NUMBER_OF_ARRAY_SCALARS = DEFAULT_MAX_NUMBER_OF_ARRAY_SCALARS;
private static final int MAX_NUMBER_OF_ARRAY_SCALARS = 100_000;
public static int getMaxNumberOfArrayScalars() {
return MAX_NUMBER_OF_ARRAY_SCALARS;
}
public static void setMaxNumberOfArrayScalars(final int maxNumberOfArrayScalars) {
MAX_NUMBER_OF_ARRAY_SCALARS = maxNumberOfArrayScalars;
}
static class ArrayDimension {
private long _size;
@ -88,7 +96,7 @@ public class Array {
}
int numberOfScalars = (int) numberOfScalarsLong;
IOUtils.safelyAllocateCheck(numberOfScalars, MAX_NUMBER_OF_ARRAY_SCALARS);
IOUtils.safelyAllocateCheck(numberOfScalars, getMaxNumberOfArrayScalars());
_values = new TypedPropertyValue[numberOfScalars];
int paddedType = (_header._type == Variant.VT_VARIANT) ? 0 : _header._type;