unz64local_GetCurrentFileInfoInternal failed to calculate current file offset
A C++/Qt ZIP library
Brought to you by:
alqualos
In QuaZIP version 0.6.2 unpacking large ZIP archives (> 4GB) failed on Mac OS 10.9 (Qt5, clang 64 bit compiler).
Debugging showed that file_info_internal.offset_curfile has not been recalculated after successfully reading a file located close to the end of a large ZIP archive. In consequence the next file header could not be read correctly.
For the setup described above the following changes helped to fix this bug:
In function unz64local_GetCurrentFileInfoInternal (file unzip.c) replace casts (ZPOS64_T)(unsigned long)-1 with (ZPOS64_T)(unsigned int)(-1)
I'd like to recommend double checking this for possible impacts on other code parts and to integrate the fix for future releases with proper checkings.
Ouch. I can't test on Mac OS, so adding tests would be somewhat pointless. And it's hard to test on large archives because it's slow. I will try to go over such parts and replace them with more portable code, though.
OK, fixed in r243 (I used (ZPOS64_T)0xFFFFFFFFu for better portability). Tested on 64-bit Linux using GCC (also turned out to have 64-bit long) and a faked "large" archives with 0-sized files using zip64 nevertheless. The resulting archive couldn't be opened in regular application, but seemed to simulate this bug correctly.