Infinite loop occurs while decompressing zip multi-volume archive file #799
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem-1
Decompress a zip multi-volume archive file without filename extension will cause an infinite loop.
payload: https://github.com/apache/commons-compress/blob/master/src/test/resources/COMPRESS-477/split_zip_created_by_zip/split_zip_created_by_zip.z01
change split_zip_created_by_zip.z01 filename to split_zip_created_by_zip, use minizip_cli to decompress this file(./minizip_cli -l /root/payloads/split_zip_created_by_zip) will cause an infinite loop.
Problem-2
Decompress multi-volume zip archive files in recover mode will cause an infinite loop.
payload: https://github.com/apache/commons-compress/blob/master/src/test/resources/COMPRESS-477/split_zip_created_by_zip/split_zip_created_by_zip.zip
split_zip_created_by_zip.zip, split_zip_created_by_zip.z01 and split_zip_created_by_zip.z02 are split zip files, put these files in a directory(do not need to change their file names). Note mz_zip.c line 1451 and line 1455(to call mz_zip_recover_cd function) , and use the patched minizip_cli to decompress split_zip_created_by_zip.zip(./minizip_cli -l /root/payloads/split_zip_created_by_zip.zip) will occur infinite loop.
I found this bug can only be triggered through mz_zip_recover_cd, split_zip_created_by_zip.zip not fail at mz_zip_read_cd, so if not note mz_zip.c can't trigger this bug. But if split_zip_created_by_zip.zip does not have a Central Directory, this bug can be triggered directly.