]> git.ipfire.org Git - thirdparty/libarchive.git/commit
tar: Keep block alignment after pax error 2637/head
authorTobias Stoeckmann <tobias@stoeckmann.org>
Sun, 25 May 2025 10:03:55 +0000 (12:03 +0200)
committerTobias Stoeckmann <tobias@stoeckmann.org>
Sun, 25 May 2025 10:03:55 +0000 (12:03 +0200)
commit101646e34e88a1eeb407bcff6db784aa12b37839
treed1209879eef44d6a0acd383a9a3a2539f651df8f
parentb6e1f06457e61c182dd2f34b9fb37701cfda041b
tar: Keep block alignment after pax error

If a pax attribute has a 0 length value and no newline, the tar reader
gets out of sync with block alignment.

This happens because the pax parser assumes that variable value_length
(which includes the terminating newline) is at least 1. To get the
real value length, 1 is subtracted. This result is subtracted from
extsize, which in this case would lead to `extsize -= -1`, i.e.
the remaining byte count is increased.

Such an unexpected calculation leads to an off-by-one when skipping
to the next block. In supplied test case, bsdtar complains that the
checksum of the next block is wrong. Since the tar parser was not
properly 512 bytes aligned, this is no surprise.

Gracefully handle such a case like GNU tar does and warn the user that
an invalid attribute has been encountered.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Makefile.am
libarchive/archive_read_support_format_tar.c
libarchive/test/CMakeLists.txt
libarchive/test/test_read_pax_empty_val_no_nl.c [new file with mode: 0644]
libarchive/test/test_read_pax_empty_val_no_nl.tar.uu [new file with mode: 0644]