Browse Source

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

Should fix https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=62170

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1912252 13f79535-47bb-0310-9956-ffa450edef68
tags/REL_5_2_4
Dominik Stadler 8 months ago
parent
commit
481c00bc6f

+ 5
- 1
poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFSheet.java View File

@@ -395,7 +395,11 @@ implements XSLFShapeContainer, Sheet<XSLFShape,XSLFTextParagraph> {
if(sp.length == 0) {
throw new IllegalStateException("CTGroupShape was not found");
}
_spTree = (CTGroupShape)sp[0];
XmlObject xmlObject = sp[0];
if (!(xmlObject instanceof CTGroupShape)) {
throw new IllegalArgumentException("Had unexpected type of entry: " + xmlObject.getClass());
}
_spTree = (CTGroupShape) xmlObject;
}
return _spTree;
}

+ 3
- 3
poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFSlide.java View File

@@ -271,9 +271,9 @@ implements Slide<XSLFShape,XSLFTextParagraph> {
*/
@Override
public XSLFBackground getBackground() {
CTBackground bg = _slide.getCSld().getBg();
if(bg != null) {
return new XSLFBackground(bg, this);
if(_slide.getCSld() != null &&
_slide.getCSld().getBg() != null) {
return new XSLFBackground(_slide.getCSld().getBg(), this);
} else {
return getMasterSheet().getBackground();
}

BIN
test-data/slideshow/clusterfuzz-testcase-minimized-POIXSLFFuzzer-5463285576892416.pptx View File


BIN
test-data/spreadsheet/stress.xls View File


Loading…
Cancel
Save