bug 62592 -- prevent StackOverflowError on corrupt thmx
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1837658 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c709b0c5d5
commit
070e815109
@ -250,6 +250,9 @@ public final class ZipPackage extends OPCPackage {
|
||||
final ZipArchiveEntry contentTypeEntry =
|
||||
zipArchive.getEntry(CONTENT_TYPES_PART_NAME);
|
||||
if (contentTypeEntry != null) {
|
||||
if (this.contentTypeManager != null) {
|
||||
throw new InvalidFormatException("ContentTypeManager can only be created once. This must be a cyclic relation?");
|
||||
}
|
||||
try {
|
||||
this.contentTypeManager = new ZipContentTypeManager(
|
||||
zipArchive.getInputStream(contentTypeEntry), this);
|
||||
|
@ -1090,6 +1090,21 @@ public final class TestPackage {
|
||||
openInvalidFile("SampleSS.txt", true);
|
||||
}
|
||||
|
||||
@Test(expected = InvalidFormatException.class)
|
||||
public void testBug62592() throws Exception {
|
||||
InputStream is = OpenXML4JTestDataSamples.openSampleStream("62592.thmx");
|
||||
OPCPackage p = OPCPackage.open(is);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBug62592SequentialCallsToGetParts() throws Exception {
|
||||
//make absolutely certain that sequential calls don't throw InvalidFormatExceptions
|
||||
String originalFile = OpenXML4JTestDataSamples.getSampleFileName("TestPackageCommon.docx");
|
||||
OPCPackage p2 = OPCPackage.open(originalFile, PackageAccess.READ);
|
||||
p2.getParts();
|
||||
p2.getParts();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDoNotCloseStream() throws IOException {
|
||||
OutputStream os = Mockito.mock(OutputStream.class);
|
||||
|
BIN
test-data/openxml4j/62592.thmx
Normal file
BIN
test-data/openxml4j/62592.thmx
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user