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
This commit is contained in:
Dominik Stadler 2024-07-14 11:26:50 +00:00
parent 7601beb592
commit fc17f113d8
5 changed files with 5 additions and 0 deletions

View 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-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( private static final Set<String> EXPECTED_FAILURES = StressTestUtils.unmodifiableHashSet(

View File

@ -516,6 +516,9 @@ public final class RecordInputStream implements LittleEndianInput {
*/ */
@Internal @Internal
public void mark(int readlimit) { 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); ((InputStream)_dataInput).mark(readlimit);
_markedDataOffset = _currentDataOffset; _markedDataOffset = _currentDataOffset;
} }

View 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-6322470200934400.xls", RuntimeException.class);
excludes.put("clusterfuzz-testcase-minimized-POIHSSFFuzzer-4819588401201152.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-6537773940867072.xls", RuntimeException.class);
excludes.put("clusterfuzz-testcase-minimized-POIHSSFFuzzer-4651309315719168.xls", RuntimeException.class);
return excludes; return excludes;
} }

Binary file not shown.