Crash in ZipFile when trying to open a large ~6Gb file


#1

Hey JUCE team. I’ve ran into a crash trying to open a ZipFile using a ~6Gb zipfile that was created with JUCE ZipBuilder.

auto selectedFile = fileChooser.getResult();
ZipFile packageZipFile(selectedFile);

In ZipFile::Init()

||centralDirectoryPos|1673525341|__int64|

this seems to return bad data:

 auto* buffer = static_cast<const char*> (headerData.getData()) + pos;
 auto fileNameLen = readUnalignedLittleEndianShort (buffer + 28);

||fileNameLen|37188|unsigned short|
|▶|buffer|0x000002adf1ffd070 “ˆ$\x1fÑJçn]šÈLxãžÊåÅ¥\vàË™BUçÒš¬D‘–6:¬S\x1dn¸úܶk\x1bwqÛ•¸«\x13×¢ôpZ9±ŸÊt¨\xe°µ¬qaÕTC\x16ýq\v,Riu–!\x1d\x1e®ÎŽ)«.ÃÖŏ\xe„Gi8¢$,´µVòV\x4K#¡‰”¼”|const char *|

Which causes this to assert on invalid string:

entries.add (new ZipEntryHolder (buffer, fileNameLen));

Any thoughts?

Thanks E


#2

I’ve ran into issues with the zip classes on files over 2GB

Only suggestion i could think is to try smaller zips, as weak as that sounds : /


#3

I really do need to be able to open large zip files. JUCE created the file and I can unzip it with a “normal” unzipper program but I need my app to be able to load large zips.


#4

The original zip file format only supports files up to 4 GB and 65,535 files. It looks like JUCE creates corrupt zip files if you create them too big, as it casts the 64 bit values to 32 bit and writes them to the file. I suppose this is fairly common and most zip programs can work around it, if you can extract your files.

There is a newer zip64 format that juce does not support which does allow for files over 4 GB and total archive size over 4 GB.

If you need to support zip files over 4 GB, look at using libzip https://libzip.org/


#5

I would love a reply from the JUCE team about this. It does seem that the ZipBuilder creates the zip file correctly as I can use Total Commander to unzip the file without issues. I could look into libzip as a replacement for the JUCE ZipBuilder but would prefer not adding any more external dependencies.

E