mirror of
https://git.savannah.gnu.org/git/tar.git
synced 2026-09-26 01:54:14 +00:00
Fix handling of extended header prefixes
* src/xheader.c (locate_handler): Recognize prefix keywords only when followed by a dot. (xattr_decoder): Use xmalloc/xstrdup instead of alloc
This commit is contained in:
+8
-7
@@ -637,11 +637,11 @@ static struct xhdr_tab const *
|
|||||||
locate_handler (char const *keyword)
|
locate_handler (char const *keyword)
|
||||||
{
|
{
|
||||||
struct xhdr_tab const *p;
|
struct xhdr_tab const *p;
|
||||||
|
|
||||||
for (p = xhdr_tab; p->keyword; p++)
|
for (p = xhdr_tab; p->keyword; p++)
|
||||||
if (p->prefix)
|
if (p->prefix)
|
||||||
{
|
{
|
||||||
if (strncmp (p->keyword, keyword, strlen(p->keyword)) == 0)
|
size_t kwlen = strlen (p->keyword);
|
||||||
|
if (keyword[kwlen] == '.' && strncmp (p->keyword, keyword, kwlen) == 0)
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -1718,17 +1718,18 @@ xattr_decoder (struct tar_stat_info *st,
|
|||||||
char *xstr, *xkey;
|
char *xstr, *xkey;
|
||||||
|
|
||||||
/* copy keyword */
|
/* copy keyword */
|
||||||
size_t klen_raw = strlen (keyword);
|
xkey = xstrdup (keyword);
|
||||||
xkey = alloca (klen_raw + 1);
|
|
||||||
memcpy (xkey, keyword, klen_raw + 1) /* including null-terminating */;
|
|
||||||
|
|
||||||
/* copy value */
|
/* copy value */
|
||||||
xstr = alloca (size + 1);
|
xstr = xmalloc (size + 1);
|
||||||
memcpy (xstr, arg, size + 1); /* separator included, for GNU tar '\n' */;
|
memcpy (xstr, arg, size + 1); /* separator included, for GNU tar '\n' */;
|
||||||
|
|
||||||
xattr_decode_keyword (xkey);
|
xattr_decode_keyword (xkey);
|
||||||
|
|
||||||
xheader_xattr_add (st, xkey + strlen("SCHILY.xattr."), xstr, size);
|
xheader_xattr_add (st, xkey + strlen ("SCHILY.xattr."), xstr, size);
|
||||||
|
|
||||||
|
free (xkey);
|
||||||
|
free (xstr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|||||||
Reference in New Issue
Block a user