From 6a19a4f5a755ebde63d7aa3d020460aea58e7ac8 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(-) (limited to 'lib') diff --git a/lib/tar/pax_header.c b/lib/tar/pax_header.c index a96a32f..95fb447 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