Skip to content

Commit

Permalink
Bug 66425: Avoid a ClassCastException found via oss-fuzz
Browse files Browse the repository at this point in the history
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

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1912157 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
centic9 committed Sep 7, 2023
1 parent 40cdc76 commit 5c2a894
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ protected XWPFHeaderFooter() {
*/
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,4 +271,12 @@ public static XWPFRelation getInstance(String rel) {
return _table.get(rel);
}

@Override
public String toString() {
return "XWPFRelation{" +
//getRelation() + "/" +
getContentType() + "/" +
getDefaultFileName() +
"}";
}
}
Binary file not shown.
Binary file modified test-data/spreadsheet/stress.xls
Binary file not shown.

0 comments on commit 5c2a894

Please sign in to comment.