diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-12-13 15:47:35 +0100 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-12-13 15:49:00 +0100 |
commit | 262fc48eb9e246ddb7315f5a14e7f6f58ca987c1 (patch) | |
tree | dc3e342ead34d15db452804d445d6621afe64a5e /lib/tar/read_header.c | |
parent | 7ab411dbd2cb066652f5f51a1bc6cc793b7cafad (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.c | 9 |
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; |