xfs: use memcpy, not strncpy, to format the attr prefix during listxattr
authorDarrick J. Wong <djwong@kernel.org>
Tue, 29 Nov 2022 01:24:42 +0000 (17:24 -0800)
committerDarrick J. Wong <djwong@kernel.org>
Wed, 30 Nov 2022 16:55:18 +0000 (08:55 -0800)
commitfd5beaff250d7e88912a937fad072d9d24f219da
tree42b1ab106ccda8b15afb063ef12e2a477e4f9169
parent032e160305f6872e590c77f11896fb28365c6d6c
xfs: use memcpy, not strncpy, to format the attr prefix during listxattr

When -Wstringop-truncation is enabled, the compiler complains about
truncation of the null byte at the end of the xattr name prefix.  This
is intentional, since we're concatenating the two strings together and
do _not_ want a null byte in the middle of the name.

We've already ensured that the name buffer is long enough to handle
prefix and name, and the prefix_len is supposed to be the length of the
prefix string without the null byte, so use memcpy here instead.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
fs/xfs/xfs_xattr.c