From: Dominik Stadler Date: Sat, 30 Dec 2023 19:39:24 +0000 (+0000) Subject: Bug 66425: Avoid exceptions found via poi-fuzz X-Git-Tag: REL_5_3_0~134 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=4d175324f2982b6b05fb7a5aea52831aeb2529e4;p=poi.git Bug 66425: Avoid exceptions found via poi-fuzz Prevent ClassCastException Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=63736 git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1915003 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/poi/src/main/java/org/apache/poi/poifs/crypt/agile/AgileEncryptionInfoBuilder.java b/poi/src/main/java/org/apache/poi/poifs/crypt/agile/AgileEncryptionInfoBuilder.java index 0674305b22..dabc789e8a 100644 --- a/poi/src/main/java/org/apache/poi/poifs/crypt/agile/AgileEncryptionInfoBuilder.java +++ b/poi/src/main/java/org/apache/poi/poifs/crypt/agile/AgileEncryptionInfoBuilder.java @@ -36,6 +36,10 @@ public class AgileEncryptionInfoBuilder implements EncryptionInfoBuilder { @Override public void initialize(EncryptionInfo info, LittleEndianInput dis) throws IOException { + if (!(dis instanceof InputStream)) { + throw new IllegalArgumentException("Had unexpected type of input: " + (dis == null ? "" : dis.getClass())); + } + EncryptionDocument ed = parseDescriptor((InputStream)dis); info.setHeader(new AgileEncryptionHeader(ed)); info.setVerifier(new AgileEncryptionVerifier(ed)); 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 6e18940a72..b239be7923 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 @@ -89,6 +89,7 @@ public abstract class BaseTestIteratingXLS { // fuzzed binaries 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); return excludes; } diff --git a/test-data/spreadsheet/clusterfuzz-testcase-minimized-POIHSSFFuzzer-6537773940867072.xls b/test-data/spreadsheet/clusterfuzz-testcase-minimized-POIHSSFFuzzer-6537773940867072.xls new file mode 100644 index 0000000000..646cf0d46a Binary files /dev/null and b/test-data/spreadsheet/clusterfuzz-testcase-minimized-POIHSSFFuzzer-6537773940867072.xls differ diff --git a/test-data/spreadsheet/stress.xls b/test-data/spreadsheet/stress.xls index 4a146faa1f..26af0e5ba3 100644 Binary files a/test-data/spreadsheet/stress.xls and b/test-data/spreadsheet/stress.xls differ