From 0654bf9d87da525765eaba7a8e7242a05c48ee02 Mon Sep 17 00:00:00 2001 From: Dominik Stadler Date: Wed, 23 Aug 2023 09:30:00 +0000 Subject: 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 --- .../org/apache/poi/xwpf/usermodel/XWPFDocument.java | 2 +- ...se-minimized-POIXWPFFuzzer-6442791109263360.docx | Bin 0 -> 4941 bytes test-data/spreadsheet/stress.xls | Bin 65536 -> 66048 bytes 3 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 test-data/document/clusterfuzz-testcase-minimized-POIXWPFFuzzer-6442791109263360.docx 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 Binary files /dev/null and b/test-data/document/clusterfuzz-testcase-minimized-POIXWPFFuzzer-6442791109263360.docx differ diff --git a/test-data/spreadsheet/stress.xls b/test-data/spreadsheet/stress.xls index 493ccd7d83..ab1d2675aa 100644 Binary files a/test-data/spreadsheet/stress.xls and b/test-data/spreadsheet/stress.xls differ -- cgit v1.2.3