diff options
author | PJ Fanning <fanningpj@apache.org> | 2022-02-19 21:06:01 +0000 |
---|---|---|
committer | PJ Fanning <fanningpj@apache.org> | 2022-02-19 21:06:01 +0000 |
commit | 189552425dae45c2ba89bb2532511c721ea85170 (patch) | |
tree | 690fdb682b7269d0038a5f64238547d69c3d83b2 | |
parent | 4496e7761fb17ec355717cdb1ed9e214e383c446 (diff) | |
download | poi-189552425dae45c2ba89bb2532511c721ea85170.tar.gz poi-189552425dae45c2ba89bb2532511c721ea85170.zip |
add extra max size config
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1898233 13f79535-47bb-0310-9956-ffa450edef68
3 files changed, 31 insertions, 4 deletions
diff --git a/poi-ooxml/src/main/java/org/apache/poi/poifs/crypt/dsig/services/TSPTimeStampService.java b/poi-ooxml/src/main/java/org/apache/poi/poifs/crypt/dsig/services/TSPTimeStampService.java index 4de2d38cf2..4f26afdb2d 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/poifs/crypt/dsig/services/TSPTimeStampService.java +++ b/poi-ooxml/src/main/java/org/apache/poi/poifs/crypt/dsig/services/TSPTimeStampService.java @@ -81,6 +81,19 @@ public class TSPTimeStampService implements TimeStampService { private static final Logger LOG = LogManager.getLogger(TSPTimeStampService.class); + // how large a timestamp response is expected to be + // can be overwritten via IOUtils.setByteArrayMaxOverride() + private static final int DEFAULT_TIMESTAMP_RESPONSE_SIZE = 10_000_000; + private static int MAX_TIMESTAMP_RESPONSE_SIZE = DEFAULT_TIMESTAMP_RESPONSE_SIZE; + + public static void setMaxTimestampResponseSize(int maxTimestampResponseSize) { + MAX_TIMESTAMP_RESPONSE_SIZE = maxTimestampResponseSize; + } + + public static int getMaxTimestampResponseSize() { + return MAX_TIMESTAMP_RESPONSE_SIZE; + } + /** * Maps the digest algorithm to corresponding OID value. */ @@ -165,7 +178,7 @@ public class TSPTimeStampService implements TimeStampService { } try (InputStream stream = huc.getInputStream()) { - responseBytes = IOUtils.toByteArray(stream); + responseBytes = IOUtils.toByteArray(stream, MAX_TIMESTAMP_RESPONSE_SIZE); } LOG.atDebug().log(() -> new SimpleMessage("response content: " + HexDump.dump(responseBytes, 0, 0))); } finally { diff --git a/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java b/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java index 06cb573e50..85512059a7 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java @@ -77,6 +77,8 @@ public class XMLSlideShow extends POIXMLDocument //arbitrarily selected; may need to increase private static final int DEFAULT_MAX_RECORD_LENGTH = 1_000_000; private static int MAX_RECORD_LENGTH = DEFAULT_MAX_RECORD_LENGTH; + private static final int DEFAULT_MAX_IMAGE_SIZE = 100_000_000; + private static int MAX_IMAGE_SIZE = DEFAULT_MAX_IMAGE_SIZE; private CTPresentation _presentation; private final List<XSLFSlide> _slides = new ArrayList<>(); @@ -101,6 +103,20 @@ public class XMLSlideShow extends POIXMLDocument return MAX_RECORD_LENGTH; } + /** + * @param length the max image size allowed for XMLSlideShow + */ + public static void setMaxImageSize(int length) { + MAX_IMAGE_SIZE = length; + } + + /** + * @return the max image size allowed for XMLSlideShow + */ + public static int getMaxImageSize() { + return MAX_IMAGE_SIZE; + } + public XMLSlideShow() { this(empty()); } @@ -556,7 +572,7 @@ public class XMLSlideShow extends POIXMLDocument */ @Override public XSLFPictureData addPicture(InputStream is, PictureType format) throws IOException { - return addPicture(IOUtils.toByteArray(is), format); + return addPicture(IOUtils.toByteArray(is, MAX_IMAGE_SIZE), format); } diff --git a/poi-ooxml/src/main/java/org/apache/poi/xslf/util/PPTHandler.java b/poi-ooxml/src/main/java/org/apache/poi/xslf/util/PPTHandler.java index 79d676ddc0..5a70ea9767 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xslf/util/PPTHandler.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xslf/util/PPTHandler.java @@ -50,14 +50,12 @@ import org.apache.poi.sl.usermodel.SlideShow; import org.apache.poi.sl.usermodel.SlideShowFactory; import org.apache.poi.util.IOUtils; import org.apache.poi.util.Internal; -import org.apache.poi.util.LocaleUtil; /** Handler for ppt and pptx files */ @Internal class PPTHandler extends MFProxy { private SlideShow<?,?> ppt; private Slide<?,?> slide; - private Charset defaultCharset = LocaleUtil.CHARSET_1252; @Override public void parse(File file) throws IOException { |