]> source.dussan.org Git - poi.git/commitdiff
Bug 66425: Avoid exceptions found via poi-fuzz
authorDominik Stadler <centic@apache.org>
Sat, 30 Dec 2023 19:39:24 +0000 (19:39 +0000)
committerDominik Stadler <centic@apache.org>
Sat, 30 Dec 2023 19:39:24 +0000 (19:39 +0000)
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

poi/src/main/java/org/apache/poi/poifs/crypt/agile/AgileEncryptionInfoBuilder.java
poi/src/test/java/org/apache/poi/hssf/dev/BaseTestIteratingXLS.java
test-data/spreadsheet/clusterfuzz-testcase-minimized-POIHSSFFuzzer-6537773940867072.xls [new file with mode: 0644]
test-data/spreadsheet/stress.xls

index 0674305b2270e1e7eca45e0410d97c0cef3d3923..dabc789e8af78c0644318ae021647463f4f5cd1f 100644 (file)
@@ -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 ? "<null>" : dis.getClass()));
+        }
+
         EncryptionDocument ed = parseDescriptor((InputStream)dis);
         info.setHeader(new AgileEncryptionHeader(ed));
         info.setVerifier(new AgileEncryptionVerifier(ed));
index 6e18940a721408af96b71254cff81b86307f129e..b239be79232c8b75a8d1e7b39c422cdaccb15f53 100644 (file)
@@ -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 (file)
index 0000000..646cf0d
Binary files /dev/null and b/test-data/spreadsheet/clusterfuzz-testcase-minimized-POIHSSFFuzzer-6537773940867072.xls differ
index 4a146faa1f53de54d33e403d1daa69b1fe411a16..26af0e5ba373a84d40f5ee9c8aef40192148132b 100644 (file)
Binary files a/test-data/spreadsheet/stress.xls and b/test-data/spreadsheet/stress.xls differ