Repository navigation
Closed
Labels
compatibilityBackwards compatibilityBackwards compatibilityencryptionEncryption/decryption issueEncryption/decryption issuefixedIssue or bug has been fixedIssue or bug has been fixedlzmaXZ compression formatXZ compression format
Description
I did compile minizip lib and app under Ubuntu Linux,
creating encrypted archive with cmd:
./minizip -9 -p test -s -m test.zip test_files/
Minizip 2.3.4 - https://github.com/nmoinvaz/minizip
---------------------------------------------------
Creating test.zip
Adding: files
Adding: files/aa2f9b0c6d77807168de5b6354db825ecd644dae
Adding: files/569c51484a2b0d735d4650a2ad5f30ed8671628c
Adding: files/0186f31ace705d241c3d9c15dcb0bbe2c3ed23d2
Adding: files/792c5132370c133764fa3b5f1df1400edaed665a
Adding: files/2e57ba74a620da726713d19a50bfa6a66be053fa
Adding: files/cc9105dbbbbb87a4bf77d22a240c926f42adc3c9
Adding: files/bceadacd8252ad296ec0d34f41b5807fba078209
Adding: files/093a45321038528a04c47a5042094e91d46e7610
Adding: files/5785ea06b012c35b6ffb3b4c7f480d435ac0d7a6
Adding: reports
Adding: reports/match.txt
Adding: reports/sysinfo_agile-pc_5b3e5ca2_0.sz
Adding: reports/bulk_extractor_out_test.txt
Adding: reports/bulk_extractor_out_test
Adding: reports/bulk_extractor_out_test/lightgrep_histogram.txt
Adding: reports/bulk_extractor_out_test/alerts.txt
Adding: reports/bulk_extractor_out_test/lightgrep.txt
Adding: reports/bulk_extractor_out_test/report.xml
unzipping it always failing with error -105.
./minizip -x -d . -p test -s -m test.zip
Minizip 2.3.4 - https://github.com/nmoinvaz/minizip
---------------------------------------------------
Creating directory: ./files/
Extracting: ./files/aa2f9b0c6d77807168de5b6354db825ecd644dae
Extracting: ./files/569c51484a2b0d735d4650a2ad5f30ed8671628c
Extracting: ./files/0186f31ace705d241c3d9c15dcb0bbe2c3ed23d2
Extracting: ./files/792c5132370c133764fa3b5f1df1400edaed665a
Extracting: ./files/2e57ba74a620da726713d19a50bfa6a66be053fa
Extracting: ./files/cc9105dbbbbb87a4bf77d22a240c926f42adc3c9
Extracting: ./files/bceadacd8252ad296ec0d34f41b5807fba078209
Extracting: ./files/093a45321038528a04c47a5042094e91d46e7610
Extracting: ./files/5785ea06b012c35b6ffb3b4c7f480d435ac0d7a6
Creating directory: ./reports/
Extracting: ./reports/match.txt
Extracting: ./reports/sysinfo_agile-pc_5b3e5ca2_0.sz
Extracting: ./reports/bulk_extractor_out_test.txt
Creating directory: ./reports/bulk_extractor_out_test/
Extracting: ./reports/bulk_extractor_out_test/lightgrep_histogram.txt
Extracting: ./reports/bulk_extractor_out_test/alerts.txt
Error -105 closing entry in zip file
Metadata
Metadata
Assignees
Labels
compatibilityBackwards compatibilityBackwards compatibilityencryptionEncryption/decryption issueEncryption/decryption issuefixedIssue or bug has been fixedIssue or bug has been fixedlzmaXZ compression formatXZ compression format
Activity
nmoinvaz commentedon Jul 7, 2018
Can you attach the files that caused this or do u have a minimally reproducible file set? Thanks.
Agile86 commentedon Jul 7, 2018
https://ufile.io/s5kao
nmoinvaz commentedon Jul 7, 2018
I think this is fixed with #275 dev branch.
Agile86 commentedon Jul 7, 2018
still reproducible with dev-branch.
Don't finalize compression stream if nothing written. #277
nmoinvaz commentedon Jul 9, 2018
Ok should be fixed now.
Agile86 commentedon Jul 9, 2018
fixed.
Finialize compression stream even if nothing written due to compatibi…
vszakats commentedon Jul 20, 2018
I'm still experiencing this issue with encrypted, zero-length (uncompressed size) entries copied over in raw mode, and also with freshly created (non-raw) encrypted entries when using DEFLATE compression.
7zais reporting this:Any hints where to look?
vszakats commentedon Jul 20, 2018
Self contained example for the DEFLATE case (I'm still investigating the LZMA raw mode one):
nmoinvaz commentedon Jul 20, 2018
Make sure you are still reading the zip entry contents (calling unzipRead..) even if the content length is zero.
nmoinvaz commentedon Jul 20, 2018
On zero-byte entries a deflate header is added some zip programs throw error when compressed size is 0 and compression method is DEFLATE. If you know ahead of time the file is going to be zero byte you can use compression method RAW.
vszakats commentedon Jul 20, 2018
The raw problem is caused by calling
zipCloseFileInZipRaw64()with zero length and zero CRC, but these values are handled as a special case downstream inmz_zip_entry_close_raw(), triggering amz_stream_crc32_get_value()call to recalculate the CRC32, resulting in an incorrect value in this case. Then the code also recalculatesuncompressed_sizeby queryingzip->crc32_stream, again resulting in a non-zero value.vszakats commentedon Jul 20, 2018
Yes, that's a check, I do read the source zip entry in case of zero-length. The problem happens when closing the entry (as described above in #277 (comment)).
5 remaining items
vszakats commentedon Jul 21, 2018
This patch fixes my test cases:
Fixed issues with closing entry when raw. #277
nmoinvaz commentedon Jul 21, 2018
I think I have fixed it another way. Please take a look. Thanks.
Improve logic around raw entry close. #277
vszakats commentedon Jul 21, 2018
Thank you! Looking good! What remains to be solved is the compatibility interface:
zipCloseFileInZipRaw*()functions now always callmz_zip_entry_close_raw(), where the latter assumes raw mode and never touches CRC/size, making non-raw entries wrong with zero CRC/size.The name of the compatibility function is to blame — it's misleading: "Raw" does not mean to imply that it serves to close raw entries only. In fact it's supposed to close any entry (non-raw or raw). So to make it minizip1 compliant, we would still need to preserve the
rawflag inzipOpenNewFileInZip*()and callmz_zip_entry_close_int()directly, with therawargument set accordingly.If this sounds reasonable to you, I can prepare a patch.
Fixed compatibility for zip close. #277
nmoinvaz commentedon Jul 22, 2018
Thanks. I have made the changes to fix it a different way to just call
mz_zip_entry_closefrom the appropriate functions. Let me know if I missed anything.Fixed correct entry close in case wrong function called. #277
vszakats commentedon Jul 22, 2018
Thank you Nathan for your fixes and patience, tests (including production code) do work perfectly now!