-
-
Notifications
You must be signed in to change notification settings - Fork 289
Remove constraint that zip64 field values be greater than 0 #319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: development
Are you sure you want to change the base?
Conversation
In ZIP64 archives, certain standard field values (like file sizes and offsets within the archive) are set to 0xFFFFFFFF, and actual values are provided in the ZIP64 extra fields. The code was requiring these values be > 0. If a value was 0, the non-ZIP64 value was returned (0xFFFFFFFF), and thus almost guaranteed to be incorrect. This patch removes that test for `compressedSize`, `uncompressedSize`, and `relativeOffsetOfLocalHeader`. While it’s unlikely for a file to have zero length, it’s not impossible, and it’s very likely for a local header to be at offset 0.
Thanks for looking into this issue. There seem to be archives that require those |
How do you create
Looking at it in HexEdit, I see the EOCD (PKWare App Note section 4.3.16):
The Zip64 end of central directory locator (4.3.15) appears just before this:
The EOCDR64 (4.3.14) is:
The CD (4.3.12) is:
The extra field breaks down as:
I'm going to use this information to see if I can't refine how my patch gets the values. |
The ZIP64 support was provided by @Ckitakishi . It seems that the sheer existence of ZIP64 extended information is enough to treat the archive as ZIP64 (taking precedence over formally setting
@JetForMe: |
To be honest, I don't remember the reason clearly 😢
I think I created it via ZIPFoundation(by modifying the max size limit), because it's hard to include a large zip64 file in repository Since I'm on vacation right now, I'll take a look at it again after that. |
Hello, recently I had a chance to investigate this PR again~ Original issueFirst, let me explain why the file attached in #318 cannot be unarchived properly,
Compatibility improvementSecondly, I think the proposed fix in this PR is reasonable. However, we should first consider improving the compatibility of ZIPFoundation’s ZIP64 implementation:
About
|
Field | Value | Notes | Comment |
---|---|---|---|
Signature | 50 4B 05 06 | Correct | |
Number of this disk | 00 00 | Should be 0xFFFF for ZIP64 | should be correct according to 4.4.1.4 |
Number of disk with start of CD | 00 00 | Should be 0xFFFF for ZIP64 | |
Total number of entries in CD on this disk | 01 00 | Should be 0xFFFF for ZIP64 | |
Total number of entries in CD | 01 00 | Should be 0xFFFF for ZIP64 | |
Size of CD | 77 00 00 00 | Should be 0xFFFFFFFF for ZIP64 | |
Offset of CD | FF FF FF FF | Correct | |
Comment length | 00 00 | Correct |
-
End of Central Directory (EOCD), according to the spec, it's not required that all fields in EOCD be set to
-1
(0xFFFF
or0xFFFFFFFF
) when an individual field exceeds its max value, and I couldn't find any other clues that imply we should set all values to max from the documentation.4.4.1.4 If one of the fields in the end of central directory
record is too small to hold required data, the field SHOULD be
set to -1 (0xFFFF or 0xFFFFFFFF) and the ZIP64 format record
SHOULD be created. -
Central Directory (CD), as mentioned earlier, the ZIP64 Extended Information field in the Central Directory does not need to include both compressed and uncompressed sizes.
Fixes #318
Changes proposed in this PR
In ZIP64 archives, certain standard values (like compressed and uncompressed file sizes, and offsets within the archive) are set to 0xFFFFFFFF, and actual values are provided in the ZIP64 extra fields. The code was requiring these values be > 0. If a value was 0, the non-ZIP64 value was returned (0xFFFFFFFF), and thus almost guaranteed to be incorrect.
This patch removes that test for
compressedSize
,uncompressedSize
, andrelativeOffsetOfLocalHeader
. While it’s unlikely for a file to have zero length, it’s not impossible, and it’s very likely for a local header to be at offset 0.Tests performed
I tested this by seeing if I could iterate over the entries of the file in the referenced bug. Before, the iterator would immediately return nothing, now it returns the expected three entries. I didn’t want to add the referenced file to the repo, and wasn’t sure of the best way to add this test.
Further info for the reviewer
None.
Open Issues
None.