summaryrefslogtreecommitdiff
path: root/lib/tar/write_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/write_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/write_header.c')
-rw-r--r--lib/tar/write_header.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/tar/write_header.c b/lib/tar/write_header.c
index c235014..acce280 100644
--- a/lib/tar/write_header.c
+++ b/lib/tar/write_header.c
@@ -133,7 +133,7 @@ static int write_schily_xattr(FILE *fp, const struct stat *orig,
struct stat sb;
for (it = xattr; it != NULL; it = it->next) {
- len = strlen(prefix) + strlen(it->key) + strlen(it->value) + 2;
+ len = strlen(prefix) + strlen(it->key) + it->value_len + 2;
total_size += num_digits(len) + 1 + len;
}
@@ -146,11 +146,12 @@ static int write_schily_xattr(FILE *fp, const struct stat *orig,
return -1;
for (it = xattr; it != NULL; it = it->next) {
- len = strlen(prefix) + strlen(it->key) + strlen(it->value) + 2;
+ len = strlen(prefix) + strlen(it->key) + it->value_len + 2;
len += num_digits(len) + 1;
- fprintf(fp, PRI_SZ " %s%s=%s\n", len,
- prefix, it->key, it->value);
+ fprintf(fp, PRI_SZ " %s%s=", len, prefix, it->key);
+ fwrite(it->value, 1, it->value_len, fp);
+ fputc('\n', fp);
}
return padd_file(fp, total_size);