-
Notifications
You must be signed in to change notification settings - Fork 3
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
Wrong value in general purpose bit flag #4
Comments
As mentioned in the documentation, zip64file only writes ZIP files in the ZIP64 format. |
Info-ZIP UnZip supports ZIP64 since version 6.0, see their website. BTW, I updated my issue text that originally had the version number for zip, not unzip. I do not own a copy of pkzip, so I cannot check this. Could you? But anyway, even without access to pkzip, I'm pretty sure that according to the ZIP specification by PKWARE section 4.4.4, the general purpose bit flag should have bit 3 set, not bit 2 (NB, counting these bits starts at 0). |
I know they (Info-ZIP) claim it, but it is not true. Do you have a sample file, which I could use to test with PKZIP? I shall compare section 4.4.4, but I must insist, that I have run literally 1000s of tests against PKZIP. |
Here are some sample files, thanks for checking!
Can you point out any specific problems with Info-ZIP's ZIP64 support? I found nothing suspicious in the files created with their tool yet. |
General Purpose Flag (local file header, offset 6 in file) zip64file: (big-endian 0808 = little-endian 0808) According to APNNOTE.txt this means: Info-Zip: 0408 big-endian = 0804 little-endian Bit 2: fast compression Both codings appear to be valid. Both ZIP files can be read by PKZIP. Info-ZIP, however, cannot handle the 0 deferred file size in the header and fails reading a.zip. This, among others, documents my problems with Info-ZIP. Conclusion: On reading Zip64File should respect the flag and not issue a warning. |
In the above comment I confused a.zip and b.zip. You are completely right: in FileEntry.java I had (The comment is OK, the value is wrong.) It should be: It is interesting, that PKWARE did not have any problems with this. Apparently they just always read the extended values after the file without worrying about the flag. |
OK, cool! Will you fix this yourself or should I prepare a pull request?
Yeah, that's weird. Or maybe they read the size from the central directory header instead? Given the amount of redundancy in a ZIP file there are lots of possibilities ... |
I had to change getDataDescriptor() such, that it would read the old SIARD files with the flag error as well as new SIARD files with the correct flag set. This should make future SIARD files accessible to Info-ZIP. |
Ah, good idea! So it's still possible to open and edit "old" SIARD files with SIARD Suite and when saving them the correct flag will be written? That's nice. |
fixed and tested it in branch dev/enter. Will merge with master branch after handling other issues. |
Problem Description
I zipped a non-empty text file with the zip64 command line tool. When I unzipped it with another tool (UnZip 6.00 of 20 April 2009, by Debian. Original by Info-ZIP.), the extracted text file was empty. The same problem occurs with files created by SIARD Suite, so this is not limited to the command line tool but the bug lurks somewhere in the library.
Analysis
(See example file below.)
I think there is a problem with the general purpose bit flag in the local file header and in the central directory file header. If I am not mistaken (which may be the case because little endian byte order makes my head hurt),
0408
resolves to 0x0804 = 0000100000000100, so bits 2 and 11 are set. (Counting starts at 0.) According to [APPNOTE section 4.4.4] bit 2 is relevant only for a specific compression type that's not used here, so it counts as undefined.Maybe it was intended to set bit 3 (0x0808) instead of 2, announcing the data descriptor that follows down below? (Bit 11 denotes UTF-8 file names and comments, so that's OK.)
If bit 3 is set instead of bit 2 the zipped file is extracted correctly.
Example File
This is the hex representation of a ZIP file created with Zip64File 2.0.60 (looks the same with 2.1.34) using the following command where hello.txt contains the string "hello world":
If you'd like to play with the hex data (like changing the general purpose bit flags), a binary ZIP file can be compiled from it using this tool.
Local File Header
Note the general purpose bit flag!
File Data
ASCII string "hello world", uncompressed. This looks fine.
Data Descriptor
Looks OK.
Central Directory Header
Note the general purpose bit flag!
End Of Central Directory Record
Looks OK.
The text was updated successfully, but these errors were encountered: