]> git.ipfire.org Git - thirdparty/libarchive.git/commit
Fix issue when skipping first file in 7zip archive that is a multiple of 65536 bytes...
authorDuncan Horn <40036384+dunhor@users.noreply.github.com>
Thu, 20 Jun 2024 03:15:13 +0000 (20:15 -0700)
committerGitHub <noreply@github.com>
Thu, 20 Jun 2024 03:15:13 +0000 (20:15 -0700)
commita578fb345a0221b000fb6c2857ae7d790febe94b
tree09b9ba591b9276fec528c15f018918dbf081f6ac
parent3fdf9bf80fd4e9473052ef68a9ce7ccebfc5472c
Fix issue when skipping first file in 7zip archive that is a multiple of 65536 bytes (#2245)

We noticed an issue where we had an archive that, if you skipped the
first entry and tried to extract the second, you'd get a failure saying
`Truncated 7-Zip file body`. Turns out that this is because the first
file in the archive is a multiple of 65,536 bytes (the size of the
uncompressed buffer) and therefore after `read_stream` skipped all of
the first file, `uncompressed_buffer_bytes_remaining` was set to zero
(because all data was consumed) and then it calls
`get_uncompressed_data` with `minimum` set to zero. This then saw that
`minimum > zip->uncompressed_buffer_bytes_remaining` evaluated to false,
causing us to read zero bytes, which got interpreted as a truncated
archive.

The fix here is simple: we now always call `extract_pack_stream` when
`uncompressed_buffer_bytes_remaining` is zero before exiting the
skipping loop.
Makefile.am
libarchive/archive_read_support_format_7zip.c
libarchive/test/test_read_format_7zip.c
libarchive/test/test_read_format_7zip_extract_second.7z.uu [new file with mode: 0644]