aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDominik Stadler <centic@apache.org>2023-12-30 19:39:31 +0000
committerDominik Stadler <centic@apache.org>2023-12-30 19:39:31 +0000
commit94ace1c4b0469d1e5909e26d47b8a76491c0b106 (patch)
treecfdddefea1c55e9fd6031c3cefe1fae0a43a0a8d
parent4d175324f2982b6b05fb7a5aea52831aeb2529e4 (diff)
downloadpoi-94ace1c4b0469d1e5909e26d47b8a76491c0b106.tar.gz
poi-94ace1c4b0469d1e5909e26d47b8a76491c0b106.zip
Bug 66425: Avoid exceptions found via poi-fuzz
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
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hwpf/converter/AbstractWordConverter.java4
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hwpf/converter/TestWordToConverterSuite.java3
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hwpf/converter/TestWordToTextConverter.java3
-rw-r--r--test-data/document/clusterfuzz-testcase-minimized-POIHWPFFuzzer-6610789829836800.docbin0 -> 39249 bytes
-rw-r--r--test-data/spreadsheet/stress.xlsbin63488 -> 63488 bytes
5 files changed, 8 insertions, 2 deletions
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/converter/AbstractWordConverter.java b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/converter/AbstractWordConverter.java
index d6f410d286..186feb2118 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/converter/AbstractWordConverter.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/converter/AbstractWordConverter.java
@@ -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();
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hwpf/converter/TestWordToConverterSuite.java b/poi-scratchpad/src/test/java/org/apache/poi/hwpf/converter/TestWordToConverterSuite.java
index efa007af47..0eb956e88c 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hwpf/converter/TestWordToConverterSuite.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hwpf/converter/TestWordToConverterSuite.java
@@ -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() {
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hwpf/converter/TestWordToTextConverter.java b/poi-scratchpad/src/test/java/org/apache/poi/hwpf/converter/TestWordToTextConverter.java
index ab9f6d6cd4..cb72d510f5 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hwpf/converter/TestWordToTextConverter.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hwpf/converter/TestWordToTextConverter.java
@@ -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
index 0000000000..85f57dba2c
--- /dev/null
+++ b/test-data/document/clusterfuzz-testcase-minimized-POIHWPFFuzzer-6610789829836800.doc
Binary files differ
diff --git a/test-data/spreadsheet/stress.xls b/test-data/spreadsheet/stress.xls
index 26af0e5ba3..f04e974e02 100644
--- a/test-data/spreadsheet/stress.xls
+++ b/test-data/spreadsheet/stress.xls
Binary files differ