From 3887a949a71f3bf2d7c17a4b4c9538d3bb7f6d86 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Thu, 10 Mar 2022 22:50:59 +0100 Subject: Cleanup libtar mkxattr, explicitly null-terminate strings Signed-off-by: David Oberhollenzer --- lib/tar/pax_header.c | 8 ++++++-- 1 file 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; } -- cgit v1.2.3