B4J Question jPOI .XLSX - ZIP bomb detected !

peacemaker

Expert
Licensed User
Longtime User
HI, All
Who's seen such error using jPOI for .XLSX file?

B4X:
Waiting for debugger to connect...
Program started.
Error occurred on line: 42
java.io.IOException: Zip bomb detected! The file would exceed the max. ratio of compressed file size to the size of the expanded data.
This may indicate that the file is used to inflate memory usage and thus could pose a security risk.
You can adjust this limit via ZipSecureFile.setMinInflateRatio() if you need to work with files which exceed this limit.
Uncompressed size: 713440, Raw/compressed size: 7128, ratio: 0.009991
Limits: MIN_INFLATE_RATIO: 0.010000, Entry: xl/styles.xml
    at org.apache.poi.openxml4j.util.ZipArchiveThresholdInputStream.checkThreshold(ZipArchiveThresholdInputStream.java:130)
    at org.apache.poi.openxml4j.util.ZipArchiveThresholdInputStream.read(ZipArchiveThresholdInputStream.java:80)
    at org.apache.poi.util.IOUtils.toByteArray(IOUtils.java:151)
    at org.apache.poi.util.IOUtils.toByteArray(IOUtils.java:120)
    at org.apache.poi.openxml4j.util.ZipArchiveFakeEntry.<init>(ZipArchiveFakeEntry.java:47)
    at org.apache.poi.openxml4j.util.ZipInputStreamZipEntrySource.<init>(ZipInputStreamZipEntrySource.java:51)
    at org.apache.poi.openxml4j.opc.ZipPackage.<init>(ZipPackage.java:106)
    at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:298)
    at org.apache.poi.xssf.usermodel.XSSFWorkbookFactory.createWorkbook(XSSFWorkbookFactory.java:129)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.poi.ss.usermodel.WorkbookFactory.createWorkbook(WorkbookFactory.java:314)
    at org.apache.poi.ss.usermodel.WorkbookFactory.createXSSFWorkbook(WorkbookFactory.java:296)
    at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:214)
    at anywheresoftware.b4j.objects.PoiWorkbookWrapper.InitializeExisting(PoiWorkbookWrapper.java:53)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

Yes, file is hard to use, but it's long text lists with macroses (.xlsm file) that is not a bomb. How to workaround ?
 
Last edited:

peacemaker

Expert
Licensed User
Longtime User
Yes, and it needs to change the setting:
B4X:
ZipSecureFile.setMinInflateRatio(0);
I guess, something by reflection, any idea how ?
@Erel, maybe any suggestion ?
 
Last edited:
Upvote 0
Top