diff options
author | Dominik Stadler <centic@apache.org> | 2023-09-06 14:58:31 +0000 |
---|---|---|
committer | Dominik Stadler <centic@apache.org> | 2023-09-06 14:58:31 +0000 |
commit | aad473eaca864b75b20d216d18302c901edd026e (patch) | |
tree | 1c432f4fbf076be41caf0a8be2d6575c29de95cf | |
parent | 5d073e35864033aea6fc3e2afeed3fad9da033a7 (diff) | |
download | poi-aad473eaca864b75b20d216d18302c901edd026e.tar.gz poi-aad473eaca864b75b20d216d18302c901edd026e.zip |
Bug 66425: Avoid a ClassCastException found via oss-fuzz
We try to avoid throwing ClassCastException, but it was possible
to trigger one here with a specially crafted input-file
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1912140 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java | 4 | ||||
-rw-r--r-- | test-data/document/clusterfuzz-testcase-minimized-POIXWPFFuzzer-4791943399604224.docx | bin | 0 -> 15932 bytes |
2 files changed, 2 insertions, 2 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 1b693b0f70..f8f99d81af 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 @@ -312,11 +312,11 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody { for (RelationPart rp : getRelationParts()) { POIXMLDocumentPart p = rp.getDocumentPart(); String relation = rp.getRelationship().getRelationshipType(); - if (relation.equals(XWPFRelation.FOOTNOTE.getRelation())) { + if (relation.equals(XWPFRelation.FOOTNOTE.getRelation()) && p instanceof XWPFFootnotes) { this.footnotes = (XWPFFootnotes) p; this.footnotes.onDocumentRead(); this.footnotes.setIdManager(footnoteIdManager); - } else if (relation.equals(XWPFRelation.ENDNOTE.getRelation())) { + } else if (relation.equals(XWPFRelation.ENDNOTE.getRelation()) && p instanceof XWPFEndnotes) { this.endnotes = (XWPFEndnotes) p; this.endnotes.onDocumentRead(); this.endnotes.setIdManager(footnoteIdManager); diff --git a/test-data/document/clusterfuzz-testcase-minimized-POIXWPFFuzzer-4791943399604224.docx b/test-data/document/clusterfuzz-testcase-minimized-POIXWPFFuzzer-4791943399604224.docx Binary files differnew file mode 100644 index 0000000000..79b696cfc1 --- /dev/null +++ b/test-data/document/clusterfuzz-testcase-minimized-POIXWPFFuzzer-4791943399604224.docx |