mirror of
https://git.savannah.gnu.org/git/tar.git
synced 2026-09-01 22:06:55 +00:00
sparse: fix pax extraction for unicode filenames
Make sure that 'GNU.sparse.name' header has higher priority than (for sparse-purposes artificially modified) 'path' pax header. Historically, the 'GNU.sparse.name' header comes before 'path'; this caused that modified 'path' header won and that is not what we want in sparse "capable" tar implementation. * src/tar.h (tar_stat_info): New argument sparse_name_done. * src/xheader.c (raw_path_decoder): Move here the unconditional code from path_decoder. (path_decoder): Apply raw_path_decoder only if sparse_path_decoder was not yet called. (sparse_path_decoder): New wrapper around raw_path_decoder. * tests/sparse07.at: New testcase. * tests/testsuite.at: Mention new testcase. * tests/Makefile.am: Likewise.
This commit is contained in:
committed by
Sergey Poznyakoff
parent
c81a0853bb
commit
00f928642f
@@ -331,6 +331,10 @@ struct tar_stat_info
|
||||
int real_size_set; /* True when GNU.sparse.realsize is set in
|
||||
archived file */
|
||||
|
||||
bool sparse_name_done; /* Set to true if 'GNU.sparse.name' header was
|
||||
processed pax header parsing. Following 'path'
|
||||
header (lower priority) will be ignored. */
|
||||
|
||||
size_t xattr_map_size; /* Size of the xattr map */
|
||||
struct xattr_array *xattr_map;
|
||||
|
||||
|
||||
+22
-4
@@ -1290,15 +1290,33 @@ path_coder (struct tar_stat_info const *st, char const *keyword,
|
||||
code_string (st->file_name, keyword, xhdr);
|
||||
}
|
||||
|
||||
static void
|
||||
raw_path_decoder (struct tar_stat_info *st, char const *arg)
|
||||
{
|
||||
decode_string (&st->orig_file_name, arg);
|
||||
decode_string (&st->file_name, arg);
|
||||
st->had_trailing_slash = strip_trailing_slashes (st->file_name);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
path_decoder (struct tar_stat_info *st,
|
||||
char const *keyword __attribute__((unused)),
|
||||
char const *arg,
|
||||
size_t size __attribute__((unused)))
|
||||
{
|
||||
decode_string (&st->orig_file_name, arg);
|
||||
decode_string (&st->file_name, arg);
|
||||
st->had_trailing_slash = strip_trailing_slashes (st->file_name);
|
||||
if (! st->sparse_name_done)
|
||||
raw_path_decoder (st, arg);
|
||||
}
|
||||
|
||||
static void
|
||||
sparse_path_decoder (struct tar_stat_info *st,
|
||||
char const *keyword __attribute__((unused)),
|
||||
char const *arg,
|
||||
size_t size __attribute__((unused)))
|
||||
{
|
||||
st->sparse_name_done = true;
|
||||
raw_path_decoder (st, arg);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1730,7 +1748,7 @@ struct xhdr_tab const xhdr_tab[] = {
|
||||
{ "uname", uname_coder, uname_decoder, 0, false },
|
||||
|
||||
/* Sparse file handling */
|
||||
{ "GNU.sparse.name", path_coder, path_decoder,
|
||||
{ "GNU.sparse.name", path_coder, sparse_path_decoder,
|
||||
XHDR_PROTECTED, false },
|
||||
{ "GNU.sparse.major", sparse_major_coder, sparse_major_decoder,
|
||||
XHDR_PROTECTED, false },
|
||||
|
||||
Reference in New Issue
Block a user