]> source.dussan.org Git - poi.git/commitdiff
Bug 66425: Avoid exceptions found via poi-fuzz
authorDominik Stadler <centic@apache.org>
Wed, 6 Dec 2023 19:49:45 +0000 (19:49 +0000)
committerDominik Stadler <centic@apache.org>
Wed, 6 Dec 2023 19:49:45 +0000 (19:49 +0000)
Change an assertion which can be triggered via an
input-document.

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

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

poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/PICFAndOfficeArtData.java
poi-scratchpad/src/test/java/org/apache/poi/hwpf/converter/TestWordToConverterSuite.java
poi-scratchpad/src/test/java/org/apache/poi/hwpf/converter/TestWordToTextConverter.java
test-data/document/clusterfuzz-testcase-minimized-POIHWPFFuzzer-4892412469968896.doc [new file with mode: 0644]
test-data/spreadsheet/stress.xls

index 59163a578ca6b3e9c4674ec8d76c9d77c155c7a7..ecf46adc838f83272b4e72bb460bfff1a6c7d8fd 100644 (file)
@@ -88,7 +88,9 @@ public class PICFAndOfficeArtData {
 
             // [MS-ODRAW] allows for multiple records in a OfficeArtInlineSpContainer, which is what we're parsing here.
             //   However, in the context of a HWPF document, there should be only 1.
-            assert _blipRecords.size() == 1;
+            if (_blipRecords.size() != 1) {
+                throw new IllegalStateException("Should only have one BLIP-Record, but had: " + _blipRecords.size());
+            }
         }
     }
 
index a2aac7b19fb4c23b9daa0440af02c20eb16c523c..efa007af47762583ea610872287d6be1b40a34d4 100644 (file)
@@ -60,7 +60,8 @@ public class TestWordToConverterSuite {
         "TestHPSFWritingFunctionality.doc",
         "clusterfuzz-testcase-minimized-POIHWPFFuzzer-4947285593948160.doc",
         "clusterfuzz-testcase-minimized-POIHWPFFuzzer-5440721166139392.doc",
-        "clusterfuzz-testcase-minimized-POIHWPFFuzzer-5050208641482752.doc"
+        "clusterfuzz-testcase-minimized-POIHWPFFuzzer-5050208641482752.doc",
+        "clusterfuzz-testcase-minimized-POIHWPFFuzzer-4892412469968896.doc"
     );
 
     public static Stream<Arguments> files() {
index 2b2cfed94e1993c3035c3dc9483465a23fa6c886..ab9f6d6cd4eeea05cfc74465c7931e2d0b0f14bf 100644 (file)
@@ -53,7 +53,8 @@ public class TestWordToTextConverter {
         "TestHPSFWritingFunctionality.doc",
         "clusterfuzz-testcase-minimized-POIHWPFFuzzer-4947285593948160.doc",
         "clusterfuzz-testcase-minimized-POIHWPFFuzzer-5440721166139392.doc",
-        "clusterfuzz-testcase-minimized-POIHWPFFuzzer-5050208641482752.doc"
+        "clusterfuzz-testcase-minimized-POIHWPFFuzzer-5050208641482752.doc",
+        "clusterfuzz-testcase-minimized-POIHWPFFuzzer-4892412469968896.doc"
     );
 
     /**
diff --git a/test-data/document/clusterfuzz-testcase-minimized-POIHWPFFuzzer-4892412469968896.doc b/test-data/document/clusterfuzz-testcase-minimized-POIHWPFFuzzer-4892412469968896.doc
new file mode 100644 (file)
index 0000000..922ebf7
Binary files /dev/null and b/test-data/document/clusterfuzz-testcase-minimized-POIHWPFFuzzer-4892412469968896.doc differ
index 1afd350acd65a620af960adcbdc38bece3959e48..31a8b184cde00a81ca81b9989e107e6b583d9b94 100644 (file)
Binary files a/test-data/spreadsheet/stress.xls and b/test-data/spreadsheet/stress.xls differ