summaryrefslogtreecommitdiff
path: root/lib/tar/read_header.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-12-13 15:47:35 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-12-13 15:49:00 +0100
commit262fc48eb9e246ddb7315f5a14e7f6f58ca987c1 (patch)
treedc3e342ead34d15db452804d445d6621afe64a5e /lib/tar/read_header.c
parent7ab411dbd2cb066652f5f51a1bc6cc793b7cafad (diff)
Better support for reading/writing non-ASCII xattr values from/to tar
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/tar/read_header.c')
-rw-r--r--lib/tar/read_header.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/tar/read_header.c b/lib/tar/read_header.c
index 845afc3..20e7a9f 100644
--- a/lib/tar/read_header.c
+++ b/lib/tar/read_header.c
@@ -68,7 +68,8 @@ static tar_xattr_t *mkxattr(const char *key, size_t keylen,
return NULL;
xattr->key = xattr->data;
- xattr->value = xattr->data + keylen + 1;
+ xattr->value = (sqfs_u8 *)xattr->data + keylen + 1;
+ xattr->value_len = valuelen;
memcpy(xattr->key, key, keylen);
memcpy(xattr->value, value, valuelen);
return xattr;
@@ -201,7 +202,8 @@ static int read_pax_header(FILE *fp, sqfs_u64 entsize, unsigned int *set_by_pax,
value = ptr + 1;
- xattr = mkxattr(key, ptr - key, value, strlen(value));
+ xattr = mkxattr(key, ptr - key,
+ value, len - (value - line) - 1);
if (xattr == NULL)
goto fail_errno;
@@ -221,7 +223,8 @@ static int read_pax_header(FILE *fp, sqfs_u64 entsize, unsigned int *set_by_pax,
goto fail_errno;
urldecode(xattr->key);
- base64_decode((sqfs_u8 *)xattr->value, value);
+ xattr->value_len = base64_decode(xattr->value, value,
+ xattr->value_len);
xattr->next = out->xattr;
out->xattr = xattr;