aboutsummaryrefslogtreecommitdiffstats
path: root/poi-ooxml
diff options
context:
space:
mode:
authorDominik Stadler <centic@apache.org>2023-10-03 06:05:30 +0000
committerDominik Stadler <centic@apache.org>2023-10-03 06:05:30 +0000
commit360c05d9e3496cb6b49e73732615fd9daedf40aa (patch)
treea9ad8a1b361f4a46e96a4276e3f4c9181bdb237d /poi-ooxml
parent105966cc29113e90a47943bed1d9752e768353ea (diff)
downloadpoi-360c05d9e3496cb6b49e73732615fd9daedf40aa.tar.gz
poi-360c05d9e3496cb6b49e73732615fd9daedf40aa.zip
Bug 66425: Avoid exceptions found via poi-fuzz
We try to avoid throwing NullPointerException, ClassCastExceptions and StackOverflowException, but it was possible to trigger them Also improve some exception messages Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=62698 https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=62606 https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=62685 git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1912707 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi-ooxml')
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFGraphicFrame.java4
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFTableCell.java4
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFSheet.java8
3 files changed, 12 insertions, 4 deletions
diff --git a/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFGraphicFrame.java b/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFGraphicFrame.java
index ceccd10635..c744f2ab73 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFGraphicFrame.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFGraphicFrame.java
@@ -67,6 +67,10 @@ public class XSLFGraphicFrame extends XSLFShape implements GraphicalFrame<XSLFSh
@Override
public Rectangle2D getAnchor(){
CTTransform2D xfrm = ((CTGraphicalObjectFrame)getXmlObject()).getXfrm();
+ if (xfrm == null) {
+ throw new IllegalArgumentException("Could not retrieve an Xfrm from the XML object");
+ }
+
CTPoint2D off = xfrm.getOff();
double x = Units.toPoints(POIXMLUnits.parseLength(off.xgetX()));
double y = Units.toPoints(POIXMLUnits.parseLength(off.xgetY()));
diff --git a/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFTableCell.java b/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFTableCell.java
index f84c37d08e..d22ab8df19 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFTableCell.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFTableCell.java
@@ -766,7 +766,7 @@ public class XSLFTableCell extends XSLFTextShape implements TableCell<XSLFShape,
return super.isBold();
} else {
final CTTextCharacterProperties rPr = super.getRPr(false);
- if (rPr.isSetB()) {
+ if (rPr != null && rPr.isSetB()) {
// If this run has bold set locally, then it overrides table cell style.
return rPr.getB();
} else {
@@ -784,7 +784,7 @@ public class XSLFTableCell extends XSLFTextShape implements TableCell<XSLFShape,
return super.isItalic();
} else {
final CTTextCharacterProperties rPr = super.getRPr(false);
- if (rPr.isSetI()) {
+ if (rPr != null && rPr.isSetI()) {
// If this run has italic set locally, then it overrides table cell style.
return rPr.getI();
} else {
diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFSheet.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFSheet.java
index ea1c7e1bfb..f74e6b0dbb 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFSheet.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFSheet.java
@@ -96,8 +96,12 @@ public class SXSSFSheet implements Sheet, OoxmlSheetExtensions {
setRandomAccessWindowSize(_workbook.getRandomAccessWindowSize());
try {
_autoSizeColumnTracker = new AutoSizeColumnTracker(this);
- } catch (UnsatisfiedLinkError | InternalError e) {
- LOG.atWarn().log("Failed to create AutoSizeColumnTracker, possibly due to fonts not being installed in your OS", e);
+ } catch (UnsatisfiedLinkError | NoClassDefFoundError | InternalError |
+ // thrown when no fonts are available in the workbook
+ IndexOutOfBoundsException e) {
+ LOG.atWarn()
+ .withThrowable(e)
+ .log("Failed to create AutoSizeColumnTracker, possibly due to fonts not being installed in your OS");
}
}