]> git.ipfire.org Git - thirdparty/libarchive.git/commit
tar: Reset accumulated header state after reading macOS metadata blob
authorZhaofeng Li <hello@zhaofeng.li>
Sat, 24 May 2025 19:45:18 +0000 (13:45 -0600)
committerZhaofeng Li <hello@zhaofeng.li>
Sat, 24 May 2025 20:33:08 +0000 (14:33 -0600)
commit5bb36db5e19aecabccec8f351ec22f8c3a8695f0
treec3696c5432ce0840ebe8bc832fa2676c9aab2c9a
parent0ed4435209b9b694cc190d937e4709a0609580e6
tar: Reset accumulated header state after reading macOS metadata blob

AppleDouble extension entries are present as separate files immediately
preceding the corresponding real files. In libarchive, we process the
entire metadata file (headers + data) as if it were a header in the real
file. However, the code forgets to reset the accumulated header state
before parsing the real file's headers. In one code path, this causes
the metadata file's name to be used as the real file's name.

Specifically, this can be triggered with a tar containing two files:

1. A file named `._badname` with pax header containing the `path` attribute
2. A file named `goodname` _with_ a pax header but _without_ the `path` attribute

libarchive will list one file, `._badname` containing the data of `goodname`.

This code is pretty brittle and we really should let the client deal with
it :(

Fixes #2510.

Signed-off-by: Zhaofeng Li <hello@zhaofeng.li>
libarchive/archive_read_support_format_tar.c