summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2022-03-10 22:50:59 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2022-03-30 23:07:52 +0200
commit3887a949a71f3bf2d7c17a4b4c9538d3bb7f6d86 (patch)
tree31d4588fea606afa1f743a43913537c73c50a300
parent5e682a087502b9dd285e829f9814eaa430070a6d (diff)
Cleanup libtar mkxattr, explicitly null-terminate strings
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
-rw-r--r--lib/tar/pax_header.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/tar/pax_header.c b/lib/tar/pax_header.c
index 448976d..c4cc701 100644
--- a/lib/tar/pax_header.c
+++ b/lib/tar/pax_header.c
@@ -18,10 +18,14 @@ static tar_xattr_t *mkxattr(const char *key, size_t keylen,
return NULL;
xattr->key = xattr->data;
- xattr->value = (sqfs_u8 *)xattr->data + keylen + 1;
- xattr->value_len = valuelen;
memcpy(xattr->key, key, keylen);
+ xattr->key[keylen] = '\0';
+
+ xattr->value = (sqfs_u8 *)xattr->key + keylen + 1;
memcpy(xattr->value, value, valuelen);
+ xattr->value[valuelen] = '\0';
+
+ xattr->value_len = valuelen;
return xattr;
}