mirror of
https://github.com/apache/poi.git
synced 2026-02-27 20:40:08 +08:00
[bug-69628] more changes to getMax methods
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1924994 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f2179098fe
commit
b3d0fe52d3
@ -123,8 +123,8 @@ public class ZipArchiveThresholdInputStream extends FilterInputStream {
|
||||
final String entryName = entry == null ? "not set" : entry.getName();
|
||||
|
||||
// check the file size first, in case we are working on uncompressed streams
|
||||
if (payloadSize > MAX_ENTRY_SIZE) {
|
||||
throw new IOException(String.format(Locale.ROOT, MAX_ENTRY_SIZE_MSG, payloadSize, rawSize, MAX_ENTRY_SIZE, entryName));
|
||||
if (payloadSize > getMaxEntrySize()) {
|
||||
throw new IOException(String.format(Locale.ROOT, MAX_ENTRY_SIZE_MSG, payloadSize, rawSize, getMaxEntrySize(), entryName));
|
||||
}
|
||||
|
||||
// don't alert for small expanded size
|
||||
|
||||
@ -107,7 +107,7 @@ public abstract class XSSFBParser {
|
||||
|
||||
}
|
||||
if (records == null || records.get(recordId)) {
|
||||
byte[] buff = IOUtils.safelyAllocate(recordLength, MAX_RECORD_LENGTH);
|
||||
byte[] buff = IOUtils.safelyAllocate(recordLength, getMaxRecordLength());
|
||||
is.readFully(buff);
|
||||
handleRecord(recordId, buff);
|
||||
} else {
|
||||
|
||||
@ -17,8 +17,6 @@
|
||||
|
||||
package org.apache.poi.hdgf.streams;
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.poi.logging.PoiLogManager;
|
||||
import org.apache.poi.hdgf.chunks.ChunkFactory;
|
||||
import org.apache.poi.hdgf.pointers.Pointer;
|
||||
import org.apache.poi.hdgf.pointers.PointerFactory;
|
||||
@ -28,8 +26,6 @@ import org.apache.poi.hdgf.pointers.PointerFactory;
|
||||
* other data too.
|
||||
*/
|
||||
public class PointerContainingStream extends Stream { // TODO - instantiable superclass
|
||||
private static final Logger LOG = PoiLogManager.getLogger(PointerContainingStream.class);
|
||||
|
||||
private static int MAX_CHILDREN_NESTING = 500;
|
||||
|
||||
private final Pointer[] childPointers;
|
||||
@ -68,9 +64,9 @@ public class PointerContainingStream extends Stream { // TODO - instantiable sup
|
||||
}
|
||||
|
||||
private void findChildren(byte[] documentData, int nesting) {
|
||||
if (nesting > MAX_CHILDREN_NESTING) {
|
||||
if (nesting > getMaxChildrenNesting()) {
|
||||
throw new IllegalArgumentException("Encountered too deep nesting, cannot process stream " +
|
||||
"with more than " + MAX_CHILDREN_NESTING + " nested children. " +
|
||||
"with more than " + getMaxChildrenNesting() + " nested children. " +
|
||||
"Some data could not be parsed. You can call setMaxChildrenNesting() to adjust " +
|
||||
"this limit.");
|
||||
}
|
||||
|
||||
@ -234,7 +234,8 @@ public final class HSSFWorkbook extends POIDocument implements Workbook {
|
||||
* @return the max image length allowed for HSSFWorkbook
|
||||
*/
|
||||
public static int getMaxImageLength() {
|
||||
return MAX_IMAGE_LENGTH;
|
||||
final int ioMaxSize = IOUtils.getByteArrayMaxOverride();
|
||||
return ioMaxSize < 0 ? MAX_IMAGE_LENGTH : Math.min(MAX_IMAGE_LENGTH, ioMaxSize);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1978,7 +1979,7 @@ public final class HSSFWorkbook extends POIDocument implements Workbook {
|
||||
case PICTURE_TYPE_WMF:
|
||||
// remove first 22 bytes if file starts with the WMF placeable header
|
||||
if (FileMagic.valueOf(pictureData) == FileMagic.WMF) {
|
||||
pictureData = IOUtils.safelyClone(pictureData, 22, pictureData.length - 22, MAX_IMAGE_LENGTH);
|
||||
pictureData = IOUtils.safelyClone(pictureData, 22, pictureData.length - 22, getMaxImageLength());
|
||||
}
|
||||
// fall through
|
||||
case PICTURE_TYPE_EMF:
|
||||
|
||||
@ -155,7 +155,7 @@ final class FunctionMetadataReader {
|
||||
// (all unspecified params are assumed to be the same as the last)
|
||||
nItems --;
|
||||
}
|
||||
byte[] result = IOUtils.safelyAllocate(nItems, MAX_RECORD_LENGTH);
|
||||
byte[] result = IOUtils.safelyAllocate(nItems, getMaxRecordLength());
|
||||
for (int i = 0; i < nItems; i++) {
|
||||
result[i] = parseOperandTypeCode(array[i]);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user