You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ce...@apache.org on 2022/03/20 06:52:55 UTC
svn commit: r1899074 - /poi/trunk/poi-ooxml/src/test/java/org/apache/poi/xwpf/usermodel/TestXWPFPictureData.java
Author: centic
Date: Sun Mar 20 06:52:55 2022
New Revision: 1899074
URL: http://svn.apache.org/viewvc?rev=1899074&view=rev
Log:
Add reproducer for possible OOM when reading pictures in XWPF
Modified:
poi/trunk/poi-ooxml/src/test/java/org/apache/poi/xwpf/usermodel/TestXWPFPictureData.java
Modified: poi/trunk/poi-ooxml/src/test/java/org/apache/poi/xwpf/usermodel/TestXWPFPictureData.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/test/java/org/apache/poi/xwpf/usermodel/TestXWPFPictureData.java?rev=1899074&r1=1899073&r2=1899074&view=diff
==============================================================================
--- poi/trunk/poi-ooxml/src/test/java/org/apache/poi/xwpf/usermodel/TestXWPFPictureData.java (original)
+++ poi/trunk/poi-ooxml/src/test/java/org/apache/poi/xwpf/usermodel/TestXWPFPictureData.java Sun Mar 20 06:52:55 2022
@@ -22,7 +22,6 @@ import static org.junit.jupiter.api.Asse
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.junit.jupiter.api.Assertions.fail;
import java.io.ByteArrayInputStream;
import java.io.IOException;
@@ -63,6 +62,20 @@ class TestXWPFPictureData {
}
}
+ @Test
+ void testReadMaxSize() throws InvalidFormatException, IOException {
+ int prev = XWPFPictureData.getMaxImageSize();
+ try {
+ // check for a regression in 5.2.1:
+ // even if we set the maximum to a very high value it should not
+ // simply allocate that much here
+ XWPFPictureData.setMaxImageSize(Integer.MAX_VALUE-1);
+ testRead();
+ } finally {
+ XWPFPictureData.setMaxImageSize(prev);
+ }
+ }
+
@Test
void testPictureInHeader() throws IOException {
try (XWPFDocument sampleDoc = XWPFTestDataSamples.openSampleDocument("headerPic.docx")) {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org