]> 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:31 +0000 (19:39 +0000)
committerDominik Stadler <centic@apache.org>
Sat, 30 Dec 2023 19:39:31 +0000 (19:39 +0000)
Prevent NullPointerException

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

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

poi-scratchpad/src/main/java/org/apache/poi/hwpf/converter/AbstractWordConverter.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-6610789829836800.doc [new file with mode: 0644]
test-data/spreadsheet/stress.xls

index d6f410d286531874915c88f4cd5b7d48d6487c78..186feb21188d263d1ce26d744501da72d10c92f8 100644 (file)
@@ -745,6 +745,10 @@ public abstract class AbstractWordConverter {
             }
             case FIELD_DROP_DOWN: {
                 Range fieldContent = field.firstSubrange(parentRange);
+                if (fieldContent == null) {
+                    throw new IllegalStateException("Cannot read field content from field " + field + " and range " + parentRange);
+                }
+
                 CharacterRun cr = fieldContent.getCharacterRun(fieldContent
                     .numCharacterRuns() - 1);
                 String[] values = cr.getDropDownListValues();
index efa007af47762583ea610872287d6be1b40a34d4..0eb956e88c909b73764194f79c8563a6c1c794eb 100644 (file)
@@ -61,7 +61,8 @@ public class TestWordToConverterSuite {
         "clusterfuzz-testcase-minimized-POIHWPFFuzzer-4947285593948160.doc",
         "clusterfuzz-testcase-minimized-POIHWPFFuzzer-5440721166139392.doc",
         "clusterfuzz-testcase-minimized-POIHWPFFuzzer-5050208641482752.doc",
-        "clusterfuzz-testcase-minimized-POIHWPFFuzzer-4892412469968896.doc"
+        "clusterfuzz-testcase-minimized-POIHWPFFuzzer-4892412469968896.doc",
+        "clusterfuzz-testcase-minimized-POIHWPFFuzzer-6610789829836800.doc"
     );
 
     public static Stream<Arguments> files() {
index ab9f6d6cd4eeea05cfc74465c7931e2d0b0f14bf..cb72d510f5d581c0611e54bd639333d3fb42ed60 100644 (file)
@@ -54,7 +54,8 @@ public class TestWordToTextConverter {
         "clusterfuzz-testcase-minimized-POIHWPFFuzzer-4947285593948160.doc",
         "clusterfuzz-testcase-minimized-POIHWPFFuzzer-5440721166139392.doc",
         "clusterfuzz-testcase-minimized-POIHWPFFuzzer-5050208641482752.doc",
-        "clusterfuzz-testcase-minimized-POIHWPFFuzzer-4892412469968896.doc"
+        "clusterfuzz-testcase-minimized-POIHWPFFuzzer-4892412469968896.doc",
+        "clusterfuzz-testcase-minimized-POIHWPFFuzzer-6610789829836800.doc"
     );
 
     /**
diff --git a/test-data/document/clusterfuzz-testcase-minimized-POIHWPFFuzzer-6610789829836800.doc b/test-data/document/clusterfuzz-testcase-minimized-POIHWPFFuzzer-6610789829836800.doc
new file mode 100644 (file)
index 0000000..85f57db
Binary files /dev/null and b/test-data/document/clusterfuzz-testcase-minimized-POIHWPFFuzzer-6610789829836800.doc differ
index 26af0e5ba373a84d40f5ee9c8aef40192148132b..f04e974e02b9326407cd541b39d69b3c150c2240 100644 (file)
Binary files a/test-data/spreadsheet/stress.xls and b/test-data/spreadsheet/stress.xls differ