]> git.ipfire.org Git - thirdparty/libarchive.git/commit
tar: Handle extra bytes after sparse entries 2643/head
authorTobias Stoeckmann <tobias@stoeckmann.org>
Tue, 27 May 2025 17:57:05 +0000 (19:57 +0200)
committerTobias Stoeckmann <tobias@stoeckmann.org>
Tue, 27 May 2025 17:57:05 +0000 (19:57 +0200)
commit715f7eac02e4c9f3b440a04fec1d5da9ce7ad823
tree6a1e21be735085a3c71435863340791848b2beb8
parent6389d172ed25de1b84606716553241c171a30111
tar: Handle extra bytes after sparse entries

Skip all entry bytes after sparse entries were encountered. This matches
GNU tar behavior.

I have adjusted (and fixed) the existing test case for this. The test
case test_read_format_gtar_sparse_skip_entry did not work with GNU tar.

In #2558 it was explained that the pax size always overrides the header
size (correct). Since the pax size in the test case was way larger than
the actual entry bytes in archive, GNU tar choke on the test file.

The libarchive parser did not skip any bytes not already read due to
references by sparse entries, so the huge pax size was not detected.

By adjusting the test case to have a leftover byte (only 3 bytes are
referenced through sparse entry now, leaving one extra byte) with a
correct pax size and an invalid header size (after all it is overridden
by pax size), GNU tar works and libarchive gets off its 512 byte
alignment, not being able to read the next entry.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
libarchive/archive_read_support_format_tar.c
libarchive/test/test_read_format_gtar_sparse_skip_entry.tar.Z.uu