You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tika.apache.org by ta...@apache.org on 2018/06/06 18:37:37 UTC
[tika] 02/02: TIKA-2446 -- prevent oom during detection of corrupt
zip -- catch POI's "could be odt exception" and POI's RuntimeException
This is an automated email from the ASF dual-hosted git repository.
tallison pushed a commit to branch branch_1x
in repository https://gitbox.apache.org/repos/asf/tika.git
commit 88fe62c8e3614c01719d64fc985158a2fd940e24
Author: tballison <ta...@mitre.org>
AuthorDate: Wed Jun 6 10:59:05 2018 -0400
TIKA-2446 -- prevent oom during detection of corrupt zip -- catch POI's
"could be odt exception" and POI's RuntimeException
---
.../org/apache/tika/parser/pkg/ZipContainerDetector.java | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/tika-parsers/src/main/java/org/apache/tika/parser/pkg/ZipContainerDetector.java b/tika-parsers/src/main/java/org/apache/tika/parser/pkg/ZipContainerDetector.java
index 453156e..e5b0b44 100644
--- a/tika-parsers/src/main/java/org/apache/tika/parser/pkg/ZipContainerDetector.java
+++ b/tika-parsers/src/main/java/org/apache/tika/parser/pkg/ZipContainerDetector.java
@@ -23,8 +23,10 @@ import org.apache.commons.compress.archivers.zip.ZipFile;
import org.apache.commons.compress.compressors.CompressorException;
import org.apache.commons.compress.compressors.CompressorStreamFactory;
import org.apache.commons.io.IOUtils;
+import org.apache.poi.UnsupportedFileFormatException;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.openxml4j.opc.OPCPackage;
+import org.apache.poi.openxml4j.opc.PackageAccess;
import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.openxml4j.opc.PackageRelationshipCollection;
import org.apache.poi.openxml4j.opc.PackageRelationshipTypes;
@@ -244,17 +246,23 @@ public class ZipContainerDetector implements Detector {
//if (zip.getEntry("_rels/.rels") != null
// || zip.getEntry("[Content_Types].xml") != null) {
// Use POI to open and investigate it for us
+ //Unfortunately, POI can throw a RuntimeException...so we
+ //have to catch that.
OPCPackage pkg = null;
try {
pkg = OPCPackage.open(zipEntrySource);
- } catch (InvalidFormatException e) {
+ } catch (SecurityException e) {
+ closeQuietly(zipEntrySource);
+ //TIKA-2571
+ throw e;
+ } catch (InvalidFormatException|RuntimeException e) {
closeQuietly(zipEntrySource);
return null;
}
+
MediaType type = null;
try {
-
// Is at an OOXML format?
type = detectOfficeOpenXML(pkg);
if (type == null) {
--
To stop receiving notification emails like this one, please contact
tallison@apache.org.