aboutsummaryrefslogtreecommitdiffstats
path: root/poi-ooxml/src
diff options
context:
space:
mode:
authorDominik Stadler <centic@apache.org>2023-09-11 18:25:13 +0000
committerDominik Stadler <centic@apache.org>2023-09-11 18:25:13 +0000
commit481c00bc6f8dbc659816b200058698e00d027808 (patch)
tree568ada329af9dd6dc5a2cbbde184253d8827b7f3 /poi-ooxml/src
parente666d3756eaea55a138e7b2b319bc70ad28bf74d (diff)
downloadpoi-481c00bc6f8dbc659816b200058698e00d027808.tar.gz
poi-481c00bc6f8dbc659816b200058698e00d027808.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 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
Diffstat (limited to 'poi-ooxml/src')
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFSheet.java6
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFSlide.java6
2 files changed, 8 insertions, 4 deletions
diff --git a/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFSheet.java b/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFSheet.java
index 4fc072ef95..128fcbd41e 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFSheet.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFSheet.java
@@ -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;
}
diff --git a/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFSlide.java b/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFSlide.java
index c48c8d162f..0b9e6a3212 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFSlide.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFSlide.java
@@ -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();
}