mirror of
https://github.com/apache/poi.git
synced 2025-03-06 17:09:08 +00:00
show full exception stack-trace if zip-bomb detection test fails
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1687197 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
27ca5d522a
commit
4a8093dc4f
@ -712,7 +712,7 @@ public final class TestPackage {
|
|||||||
Workbook wb = WorkbookFactory.create(file);
|
Workbook wb = WorkbookFactory.create(file);
|
||||||
wb.close();
|
wb.close();
|
||||||
|
|
||||||
// check ratio ouf of bounds
|
// check ratio out of bounds
|
||||||
ZipSecureFile.setMinInflateRatio(min_ratio+0.002);
|
ZipSecureFile.setMinInflateRatio(min_ratio+0.002);
|
||||||
try {
|
try {
|
||||||
wb = WorkbookFactory.create(file);
|
wb = WorkbookFactory.create(file);
|
||||||
@ -721,11 +721,15 @@ public final class TestPackage {
|
|||||||
// depending if this executed via "ant test" or within eclipse
|
// depending if this executed via "ant test" or within eclipse
|
||||||
// maybe a difference in JDK ...
|
// maybe a difference in JDK ...
|
||||||
} catch (InvalidFormatException e) {
|
} catch (InvalidFormatException e) {
|
||||||
assertEquals("Zip bomb detected! Exiting.", e.getMessage());
|
if(!e.getMessage().equals("Zip bomb detected! Exiting.")) {
|
||||||
|
throw new IllegalStateException(e);
|
||||||
|
}
|
||||||
} catch (POIXMLException e) {
|
} catch (POIXMLException e) {
|
||||||
InvocationTargetException t = (InvocationTargetException)e.getCause();
|
InvocationTargetException t = (InvocationTargetException)e.getCause();
|
||||||
IOException t2 = (IOException)t.getTargetException();
|
IOException t2 = (IOException)t.getTargetException();
|
||||||
assertEquals("Zip bomb detected! Exiting.", t2.getMessage());
|
if(!t2.getMessage().equals("Zip bomb detected! Exiting.")) {
|
||||||
|
throw new IllegalStateException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// check max entry size ouf of bounds
|
// check max entry size ouf of bounds
|
||||||
@ -735,11 +739,15 @@ public final class TestPackage {
|
|||||||
wb = WorkbookFactory.create(file, null, true);
|
wb = WorkbookFactory.create(file, null, true);
|
||||||
wb.close();
|
wb.close();
|
||||||
} catch (InvalidFormatException e) {
|
} catch (InvalidFormatException e) {
|
||||||
assertEquals("Zip bomb detected! Exiting.", e.getMessage());
|
if(!e.getMessage().equals("Zip bomb detected! Exiting.")) {
|
||||||
|
throw new IllegalStateException(e);
|
||||||
|
}
|
||||||
} catch (POIXMLException e) {
|
} catch (POIXMLException e) {
|
||||||
InvocationTargetException t = (InvocationTargetException)e.getCause();
|
InvocationTargetException t = (InvocationTargetException)e.getCause();
|
||||||
IOException t2 = (IOException)t.getTargetException();
|
IOException t2 = (IOException)t.getTargetException();
|
||||||
assertEquals("Zip bomb detected! Exiting.", t2.getMessage());
|
if(!t2.getMessage().equals("Zip bomb detected! Exiting.")) {
|
||||||
|
throw new IllegalStateException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
// reset otherwise a lot of ooxml tests will fail
|
// reset otherwise a lot of ooxml tests will fail
|
||||||
|
Loading…
x
Reference in New Issue
Block a user