Author: centic Date: Thu Sep 7 08:35:23 2023 New Revision: 1912157 URL: http://svn.apache.org/viewvc?rev=1912157&view=rev Log: 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 Fixes https://oss-fuzz.com/testcase-detail/4959857092198400 Added: poi/trunk/test-data/document/clusterfuzz-testcase-minimized-POIXWPFFuzzer-4959857092198400.docx (with props) Modified: poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFHeaderFooter.java poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFRelation.java poi/trunk/test-data/spreadsheet/stress.xls Modified: poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFHeaderFooter.java URL: http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFHeaderFooter.java?rev=1912157&r1=1912156&r2=1912157&view=diff ============================================================================== --- poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFHeaderFooter.java (original) +++ poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFHeaderFooter.java Thu Sep 7 08:35:23 2023 @@ -71,11 +71,11 @@ public abstract class XWPFHeaderFooter e */ public XWPFHeaderFooter(POIXMLDocumentPart parent, PackagePart part) { super(parent, part); - this.document = (XWPFDocument) getParent(); - - if (this.document == null) { - throw new NullPointerException(); + final POIXMLDocumentPart p = getParent(); + if (!(p instanceof XWPFDocument)) { + throw new IllegalArgumentException("Had unexpected type of parent: " + (p == null ? "<null>" : p.getClass())); } + this.document = (XWPFDocument) p; } @Override Modified: poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFRelation.java URL: http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFRelation.java?rev=1912157&r1=1912156&r2=1912157&view=diff ============================================================================== --- poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFRelation.java (original) +++ poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFRelation.java Thu Sep 7 08:35:23 2023 @@ -271,4 +271,12 @@ public final class XWPFRelation extends return _table.get(rel); } + @Override + public String toString() { + return "XWPFRelation{" + + //getRelation() + "/" + + getContentType() + "/" + + getDefaultFileName() + + "}"; + } } Added: poi/trunk/test-data/document/clusterfuzz-testcase-minimized-POIXWPFFuzzer-4959857092198400.docx URL: http://svn.apache.org/viewvc/poi/trunk/test-data/document/clusterfuzz-testcase-minimized-POIXWPFFuzzer-4959857092198400.docx?rev=1912157&view=auto ============================================================================== Binary file - no diff available. Propchange: poi/trunk/test-data/document/clusterfuzz-testcase-minimized-POIXWPFFuzzer-4959857092198400.docx ------------------------------------------------------------------------------ --- svn:mime-type (added) +++ svn:mime-type Thu Sep 7 08:35:23 2023 @@ -0,0 +1 @@ +application/vnd.openxmlformats-officedocument.wordprocessingml.document Modified: poi/trunk/test-data/spreadsheet/stress.xls URL: http://svn.apache.org/viewvc/poi/trunk/test-data/spreadsheet/stress.xls?rev=1912157&r1=1912156&r2=1912157&view=diff ============================================================================== Binary files - no diff available. --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@poi.apache.org For additional commands, e-mail: commits-h...@poi.apache.org