8000 tar: Keep block alignment after pax error by stoeckmann · Pull Request #2637 · libarchive/libarchive · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

tar: Keep block alignment after pax error #2637

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

Merged
merged 1 commit into from
May 25, 2025

Conversation

stoeckmann
Copy link
Contributor

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.

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>
@kientzle kientzle merged commit 341dd5d into libarchive:master May 25, 2025
20 checks passed
mmatuska pushed a commit that referenced this pull request May 31, 2025
tar: Keep block alignment after pax error
(cherry picked from commit 341dd5d)
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.

2 participants
0