I've been testing zipping of big files (basically just full on random content files) and noticed an issue with compressed size values in the Zip64 extra field in the local header when streaming mode is disabled.
The issue is this:
- At the very start at entry open the uncompressed size is big, but at that point compressed size is zero. So in the Zip64 extra field in the local header there is only one field with the uncompressed size.
- At the end at entry close now both uncompressed and compressed sizes are > UINT32_MAX. The values in the base local header fields get updated to UINT32_MAX, but there is no expected value for the compressed size in the Zip64 extra field entry.
Also there is a similar twin issue, when uncompressed size is less than UINT32_MAX, but compressed size is bigger. The result is similar, but now without the Zip64 extra entry in the local header at all.
So with that we have a proper central directory header, as we have all of the info at that point, but it is impossible to get the compressed size from the local header. This breaks some of the unzipping tools.
I've made a sloppy attempt to fix it here: Eswcvlad@3b01a37 .
The fix boils down to the following:
- In case there is a Zip64 extra field entry created, uncompressed and compressed sizes are both written. Judging from the PKWARE zip spec (4.5.3) it should be this way in the local headers anyway.
- At entry closing now both the base compressed size and the compressed size in the Zip64 is updated.
It seems to be working, but it is sloppy, affects streaming mode and I am not sure if it is save for other cases (like archive splitting).
Could you have a look at this?
I've been testing zipping of big files (basically just full on random content files) and noticed an issue with compressed size values in the Zip64 extra field in the local header when streaming mode is disabled.
The issue is this:
Also there is a similar twin issue, when uncompressed size is less than UINT32_MAX, but compressed size is bigger. The result is similar, but now without the Zip64 extra entry in the local header at all.
So with that we have a proper central directory header, as we have all of the info at that point, but it is impossible to get the compressed size from the local header. This breaks some of the unzipping tools.
I've made a sloppy attempt to fix it here: Eswcvlad@3b01a37 .
The fix boils down to the following:
It seems to be working, but it is sloppy, affects streaming mode and I am not sure if it is save for other cases (like archive splitting).
Could you have a look at this?