Skip to content
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

7zip: Use compression settings from file also for file header #1532

Merged
merged 2 commits into from May 27, 2021

Conversation

Gei0r
Copy link
Contributor

@Gei0r Gei0r commented May 18, 2021

The 7zip writer currently uses hard-coded values for the header compression (lzma1 if available and compression level 6).
This PR changes this behavior, so that the header is encoded in the same way as the rest of the archive.

I came across this when trying to read libarchive-created 7z file with the Apache Commons Compress Java Library. Because libarchive encoded the header differently then the rest of the file, the Java library failed with the error message "Compressed data is corrupt".

One could argue that this a bug with the Java library, but I think it's also a good thing for libarchive to use the same compression settings throughout the archive.

I have tried this version with different combinations of algorithm and compression level settings, and the files are all readable without problem with 7-zip.

@@ -755,14 +755,19 @@ _7z_close(struct archive_write *a)
*/
#if HAVE_LZMA_H
header_compression = _7Z_LZMA1;
if(zip->opt_compression == _7Z_LZMA2 ||
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Libarchive sources use tabs for indentation; please be consistent.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you, fixed.

@kientzle
Copy link
Contributor

Nice!

@kientzle
Copy link
Contributor

Do any tests need to be updated?

@Gei0r
Copy link
Contributor Author

Gei0r commented May 19, 2021

All the tests still pass; I don't know if there should be any tests about such minute details.

@mmatuska mmatuska merged commit 34456b9 into libarchive:master May 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants