]> git.ipfire.org Git - thirdparty/libarchive.git/commit
Pax parsing should consistently use the FIRST pathname/linkname (#2264)
authorTim Kientzle <kientzle@acm.org>
Tue, 9 Jul 2024 11:55:23 +0000 (04:55 -0700)
committerGitHub <noreply@github.com>
Tue, 9 Jul 2024 11:55:23 +0000 (13:55 +0200)
commit586a9645102c87d83919015a9e2e49aec7d47a63
tree6df63f76119da1024ae728a27ef0cc6685015116
parent9fa8449fbc72d077ba1b04370af0803fd129e5b3
Pax parsing should consistently use the FIRST pathname/linkname (#2264)

Pax introduced new headers that appear _before_ the legacy
headers.  So pax archives require earlier properties to
override later ones.

Originally, libarchive handled this by storing the early
headers in memory so that it could do the actual parsing
from back to front.  With this scheme, properties from
early headers were parsed last and simply overwrote
properties from later headers.

PR #2127 reduced memory usage by parsing headers in the
order they appear in the file, which requires later headers
to avoid overwriting already-set properties.  Apparently,
when I made this change, I did not fully consider how charset
translations get handled on Windows, so failed to consistently
recognize when the path or linkname properties were in fact
actually set.  As a result, the legacy path/link values (which have
no charset information) overwrote the pax path/link values (which
are known to be UTF-8), leading to the behavior observed in
#2248.  This PR corrects this bug by adding additional
tests to see if the wide character path or linkname properties
are set.

Related:  This bug was exposed by a new test added in #2228
which does a write/read validation to ensure round-trip filename
handling. This was modified in #2248 to avoid tickling the bug above.
I've reverted the change from #2248 since it's no longer necessary.
I have also added some additional validation to this test to
help ensure that the intermediate archive actually is a pax
format that includes the expected path and linkname properties
in the expected places.
libarchive/archive_read_support_format_tar.c
libarchive/test/test_pax_filename_encoding.c