From fc17f113d8a14341bc753231877d0d9b3c312118 Mon Sep 17 00:00:00 2001 From: Dominik Stadler Date: Sun, 14 Jul 2024 11:26:50 +0000 Subject: [PATCH] Bug 66425: Avoid exceptions found via poi-fuzz 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 --- .../org/apache/poi/stress/TestAllFiles.java | 1 + .../poi/hssf/record/RecordInputStream.java | 3 +++ .../poi/hssf/dev/BaseTestIteratingXLS.java | 1 + ...nimized-POIHSSFFuzzer-4651309315719168.xls | Bin 0 -> 8704 bytes test-data/spreadsheet/stress.xls | Bin 67584 -> 68096 bytes 5 files changed, 5 insertions(+) create mode 100644 test-data/spreadsheet/clusterfuzz-testcase-minimized-POIHSSFFuzzer-4651309315719168.xls diff --git a/poi-integration/src/test/java/org/apache/poi/stress/TestAllFiles.java b/poi-integration/src/test/java/org/apache/poi/stress/TestAllFiles.java index 2767ca9f72..e54f7da1d6 100644 --- a/poi-integration/src/test/java/org/apache/poi/stress/TestAllFiles.java +++ b/poi-integration/src/test/java/org/apache/poi/stress/TestAllFiles.java @@ -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 EXPECTED_FAILURES = StressTestUtils.unmodifiableHashSet( diff --git a/poi/src/main/java/org/apache/poi/hssf/record/RecordInputStream.java b/poi/src/main/java/org/apache/poi/hssf/record/RecordInputStream.java index caeac85d66..06420f394b 100644 --- a/poi/src/main/java/org/apache/poi/hssf/record/RecordInputStream.java +++ b/poi/src/main/java/org/apache/poi/hssf/record/RecordInputStream.java @@ -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; } diff --git a/poi/src/test/java/org/apache/poi/hssf/dev/BaseTestIteratingXLS.java b/poi/src/test/java/org/apache/poi/hssf/dev/BaseTestIteratingXLS.java index b239be7923..5ac8864f17 100644 --- a/poi/src/test/java/org/apache/poi/hssf/dev/BaseTestIteratingXLS.java +++ b/poi/src/test/java/org/apache/poi/hssf/dev/BaseTestIteratingXLS.java @@ -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 index 0000000000000000000000000000000000000000..7563fb2475da623eb2f933203d2695fdaf500f7c GIT binary patch literal 8704 zcmeHNYiv}<6`s3$*X-Kh7Y1Cy?1I9pj+vaH-WAHjQUa#Htniv$> zn?xj~4ONp$ZRw9Dr4mx2v`SSqO;aJ3CPhso8X76B6g3S5sj7-9AmNq7c>A4m=dQ1> z*TLqc{^*$R&YUyvnKNh3oaOBMY3F|StLf*3C6o)h7>v3^f{CvnP2i9!gbfLz2cyxb z&J+U4`x_XX=Mw-Y-~tkX3}7NK z2}lM~04kdXqyv)yJ1_;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