From ed1c6b8c0014df00e87123d355f888f72dc70e1b Mon Sep 17 00:00:00 2001 From: David Sterba Date: Tue, 25 Jun 2024 17:03:36 +0200 Subject: [PATCH] btrfs-progs: convert: copy whole xattr name buffer Commit 4db925911c6bbb ("btrfs-progs: use strncpy_null everywhere") replaced strncpy with strncpy_null, the maximum xattr name length is 255 (current limit), the target buffer is large enough for the whole size so make sure the last character is also copied. Signed-off-by: David Sterba --- convert/source-ext2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/convert/source-ext2.c b/convert/source-ext2.c index 5efaaa4b..becfd377 100644 --- a/convert/source-ext2.c +++ b/convert/source-ext2.c @@ -639,7 +639,7 @@ static int ext2_copy_single_xattr(struct btrfs_trans_handle *trans, data = databuf; datalen = bufsize; } - strncpy_null(namebuf, xattr_prefix_table[name_index], XATTR_NAME_MAX); + strncpy_null(namebuf, xattr_prefix_table[name_index], XATTR_NAME_MAX + 1); strncat(namebuf, EXT2_EXT_ATTR_NAME(entry), entry->e_name_len); if (name_len + datalen > BTRFS_LEAF_DATA_SIZE(root->fs_info) - sizeof(struct btrfs_item) - sizeof(struct btrfs_dir_item)) {