summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDominik Stadler <centic@apache.org>2023-08-23 09:30:00 +0000
committerDominik Stadler <centic@apache.org>2023-08-23 09:30:00 +0000
commit0654bf9d87da525765eaba7a8e7242a05c48ee02 (patch)
tree3f86f1953dfd9e1153c54e4c8bc73ce635431276
parentfd29772be6b3410629eff5bc376b489852d7ee6d (diff)
downloadpoi-0654bf9d87da525765eaba7a8e7242a05c48ee02.tar.gz
poi-0654bf9d87da525765eaba7a8e7242a05c48ee02.zip
Bug 66425: Avoid a NullPointerException found via oss-fuzz
We try to avoid throwing NullPointerException, but it was possible to trigger one here with a specially crafted input-file Should fix https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=61520 git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1911863 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java2
-rw-r--r--test-data/document/clusterfuzz-testcase-minimized-POIXWPFFuzzer-6442791109263360.docxbin0 -> 4941 bytes
-rw-r--r--test-data/spreadsheet/stress.xlsbin65536 -> 66048 bytes
3 files changed, 1 insertions, 1 deletions
diff --git a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java
index b5c926967e..1b693b0f70 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java
@@ -233,7 +233,7 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
}
}
// Sort out headers and footers
- if (doc.getDocument().getBody().getSectPr() != null) {
+ if (doc.getDocument().getBody() != null && doc.getDocument().getBody().getSectPr() != null) {
headerFooterPolicy = new XWPFHeaderFooterPolicy(this);
}
diff --git a/test-data/document/clusterfuzz-testcase-minimized-POIXWPFFuzzer-6442791109263360.docx b/test-data/document/clusterfuzz-testcase-minimized-POIXWPFFuzzer-6442791109263360.docx
new file mode 100644
index 0000000000..53b8a69712
--- /dev/null
+++ b/test-data/document/clusterfuzz-testcase-minimized-POIXWPFFuzzer-6442791109263360.docx
Binary files differ
diff --git a/test-data/spreadsheet/stress.xls b/test-data/spreadsheet/stress.xls
index 493ccd7d83..ab1d2675aa 100644
--- a/test-data/spreadsheet/stress.xls
+++ b/test-data/spreadsheet/stress.xls
Binary files differ