aboutsummaryrefslogtreecommitdiffstats
path: root/poi-integration/src/test
diff options
context:
space:
mode:
authorDominik Stadler <centic@apache.org>2023-09-07 12:20:28 +0000
committerDominik Stadler <centic@apache.org>2023-09-07 12:20:28 +0000
commite686e84512ce1518885750899ad543fb32e03253 (patch)
tree5b38ee982e843f11923806237042f062a6b26da8 /poi-integration/src/test
parent5c2a89412b08c4b71f2ab79b88f26827028916b4 (diff)
downloadpoi-e686e84512ce1518885750899ad543fb32e03253.tar.gz
poi-e686e84512ce1518885750899ad543fb32e03253.zip
Bug 66425: Avoid a ClassCastException found via oss-fuzz
We try to avoid throwing ClassCastException, but it was possible to trigger one here with a specially crafted input-file Also add SXSSFWorkbook.write() to integrationtests Fixes https://oss-fuzz.com/testcase-detail/5185049589579776 git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1912162 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi-integration/src/test')
-rw-r--r--poi-integration/src/test/java/org/apache/poi/stress/XSSFFileHandler.java9
1 files changed, 9 insertions, 0 deletions
diff --git a/poi-integration/src/test/java/org/apache/poi/stress/XSSFFileHandler.java b/poi-integration/src/test/java/org/apache/poi/stress/XSSFFileHandler.java
index d8c1108906..1f75723c66 100644
--- a/poi-integration/src/test/java/org/apache/poi/stress/XSSFFileHandler.java
+++ b/poi-integration/src/test/java/org/apache/poi/stress/XSSFFileHandler.java
@@ -28,6 +28,7 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.OutputStream;
import java.io.PrintStream;
import java.util.HashSet;
import java.util.Iterator;
@@ -54,6 +55,7 @@ import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.util.IOUtils;
import org.apache.poi.xssf.eventusermodel.XSSFReader;
import org.apache.poi.xssf.extractor.XSSFExportToXml;
+import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.apache.poi.xssf.usermodel.XSSFMap;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
@@ -115,6 +117,13 @@ public class XSSFFileHandler extends SpreadsheetHandler {
// and finally ensure that exporting to XML works
exportToXML(wb);
+ // also try to read and write the sheet via SXSSF
+ try (SXSSFWorkbook swb = new SXSSFWorkbook(wb)) {
+ try (OutputStream out = NullOutputStream.INSTANCE) {
+ swb.write(out);
+ }
+ }
+
// this allows to trigger a heap-dump at this point to see which memory is still allocated
//HeapDump.dumpHeap("/tmp/poi.hprof", false);