We try to generally avoid overly large allocations in places
where arrays are allocated.
We add one more such check for pictures in HSLF.
We might need to increase the used value of 10MB if users report
larger files being used frequently.
Overriding this check via IOUtils is possible.
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@
1911525 13f79535-47bb-0310-9956-
ffa450edef68
private static final int DEFAULT_MAX_RECORD_LENGTH = 200_000_000;
private static final int MAX_DOCUMENT_SIZE = 100_000_000;
private static int MAX_RECORD_LENGTH = DEFAULT_MAX_RECORD_LENGTH;
+ private static final int MAX_IMAGE_LENGTH = 10_000_000;
// Holds metadata on where things are in our document
private CurrentUserAtom currentUser;
EscherContainerRecord blipStore = getBlipStore();
byte[] pictstream;
try (DocumentInputStream is = getDirectory().createDocumentInputStream(entry)) {
- pictstream = IOUtils.toByteArray(is, entry.getSize());
+ pictstream = IOUtils.toByteArray(is, entry.getSize(), MAX_IMAGE_LENGTH);
}
List<PictureFactory> factories = new ArrayList<>();
==================================================================== */
package org.apache.poi.hslf.dev;
-import static org.junit.jupiter.api.Assertions.assertThrows;
+import org.apache.poi.EmptyFileException;
+import org.apache.poi.hslf.HSLFTestDataSamples;
+import org.junit.jupiter.api.Test;
import java.io.File;
import java.util.Collections;
+import java.util.HashSet;
import java.util.Set;
-import org.apache.poi.EmptyFileException;
-import org.apache.poi.hslf.HSLFTestDataSamples;
-import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertThrows;
public class TestPPTXMLDump extends BaseTestPPTIterating {
+ static final Set<String> LOCAL_EXCLUDED = new HashSet<>();
+ static {
+ LOCAL_EXCLUDED.add("clusterfuzz-testcase-minimized-POIHSLFFuzzer-5306877435838464.ppt");
+ }
+
@Test
void testMain() throws Exception {
PPTXMLDump.main(new String[0]);
@Override
void runOneFile(File pFile) throws Exception {
- PPTXMLDump.main(new String[]{pFile.getAbsolutePath()});
+ try {
+ PPTXMLDump.main(new String[]{pFile.getAbsolutePath()});
+ } catch (IndexOutOfBoundsException e) {
+ if (!LOCAL_EXCLUDED.contains(pFile.getName())) {
+ throw e;
+ }
+ }
}
@Override
import java.io.File;
import java.io.IOException;
+import java.util.HashSet;
+import java.util.Set;
import org.apache.poi.EmptyFileException;
import org.apache.poi.hslf.HSLFTestDataSamples;
import org.junit.jupiter.api.Test;
public class TestSlideIdListing extends BaseTestPPTIterating {
+ static final Set<String> LOCAL_EXCLUDED = new HashSet<>();
+ static {
+ LOCAL_EXCLUDED.add("clusterfuzz-testcase-minimized-POIHSLFFuzzer-5306877435838464.ppt");
+ }
+
@Test
void testMain() throws IOException {
// calls System.exit(): SlideIdListing.main(new String[0]);
@Override
void runOneFile(File pFile) throws Exception {
- SlideIdListing.main(new String[]{pFile.getAbsolutePath()});
+ try {
+ SlideIdListing.main(new String[]{pFile.getAbsolutePath()});
+ } catch (IllegalArgumentException e) {
+ if (!LOCAL_EXCLUDED.contains(pFile.getName())) {
+ throw e;
+ }
+ }
}
}
\ No newline at end of file