]> source.dussan.org Git - poi.git/commitdiff
Bug 66425: Avoid exceptions found via poi-fuzz
authorDominik Stadler <centic@apache.org>
Sun, 14 Jul 2024 11:26:50 +0000 (11:26 +0000)
committerDominik Stadler <centic@apache.org>
Sun, 14 Jul 2024 11:26:50 +0000 (11:26 +0000)
Prevent a ClassCastException

Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=66089

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1919214 13f79535-47bb-0310-9956-ffa450edef68

poi-integration/src/test/java/org/apache/poi/stress/TestAllFiles.java
poi/src/main/java/org/apache/poi/hssf/record/RecordInputStream.java
poi/src/test/java/org/apache/poi/hssf/dev/BaseTestIteratingXLS.java
test-data/spreadsheet/clusterfuzz-testcase-minimized-POIHSSFFuzzer-4651309315719168.xls [new file with mode: 0644]
test-data/spreadsheet/stress.xls

index 2767ca9f72382e566d06f6a7f2ff8375a6dff680..e54f7da1d691b251c50d7457e5d4f10de71c7267 100644 (file)
@@ -137,6 +137,7 @@ public class TestAllFiles {
         "spreadsheet/clusterfuzz-testcase-minimized-POIXSSFFuzzer-5089447305609216.xlsx",
         "spreadsheet/clusterfuzz-testcase-minimized-POIXSSFFuzzer-5089447305609216.xlsx",
         "spreadsheet/clusterfuzz-testcase-minimized-POIXSSFFuzzer-5089447305609216.xlsx",
+        "spreadsheet/clusterfuzz-testcase-minimized-POIHSSFFuzzer-4651309315719168.xls",
     });
 
     private static final Set<String> EXPECTED_FAILURES = StressTestUtils.unmodifiableHashSet(
index caeac85d666e1c39998a055ac21143703cf3dd5a..06420f394be8f6b16fd05aab8924bcc65dc8bdbb 100644 (file)
@@ -516,6 +516,9 @@ public final class RecordInputStream implements LittleEndianInput {
      */
     @Internal
     public void mark(int readlimit) {
+        if (!(_dataInput instanceof InputStream)) {
+            throw new IllegalStateException("Cannot use mark for dataInput of type " + _dataInput.getClass() + ", need an InputStream");
+        }
         ((InputStream)_dataInput).mark(readlimit);
         _markedDataOffset = _currentDataOffset;
     }
index b239be79232c8b75a8d1e7b39c422cdaccb15f53..5ac8864f172ebf94801fb787cf71b2a7180d9092 100644 (file)
@@ -90,6 +90,7 @@ public abstract class BaseTestIteratingXLS {
         excludes.put("clusterfuzz-testcase-minimized-POIHSSFFuzzer-6322470200934400.xls", RuntimeException.class);
         excludes.put("clusterfuzz-testcase-minimized-POIHSSFFuzzer-4819588401201152.xls", RuntimeException.class);
         excludes.put("clusterfuzz-testcase-minimized-POIHSSFFuzzer-6537773940867072.xls", RuntimeException.class);
+        excludes.put("clusterfuzz-testcase-minimized-POIHSSFFuzzer-4651309315719168.xls", RuntimeException.class);
         return excludes;
     }
 
diff --git a/test-data/spreadsheet/clusterfuzz-testcase-minimized-POIHSSFFuzzer-4651309315719168.xls b/test-data/spreadsheet/clusterfuzz-testcase-minimized-POIHSSFFuzzer-4651309315719168.xls
new file mode 100644 (file)
index 0000000..7563fb2
Binary files /dev/null and b/test-data/spreadsheet/clusterfuzz-testcase-minimized-POIHSSFFuzzer-4651309315719168.xls differ
index 3baca6559b3895997aa86ed0d870a5773f371563..7f0fb70430ae9112cbaa4e45583e3639d8b9007e 100644 (file)
Binary files a/test-data/spreadsheet/stress.xls and b/test-data/spreadsheet/stress.xls differ