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/write_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/write_header.c')
-rw-r--r-- | lib/tar/write_header.c | 9 |
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); |