提交 fd5beaff 编写于 作者: D Darrick J. Wong

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: NDarrick J. Wong <djwong@kernel.org>
Reviewed-by: NGao Xiang <hsiangkao@linux.alibaba.com>
Reviewed-by: NDave Chinner <dchinner@redhat.com>
上级 032e1603
...@@ -210,7 +210,7 @@ __xfs_xattr_put_listent( ...@@ -210,7 +210,7 @@ __xfs_xattr_put_listent(
return; return;
} }
offset = context->buffer + context->count; offset = context->buffer + context->count;
strncpy(offset, prefix, prefix_len); memcpy(offset, prefix, prefix_len);
offset += prefix_len; offset += prefix_len;
strncpy(offset, (char *)name, namelen); /* real name */ strncpy(offset, (char *)name, namelen); /* real name */
offset += namelen; offset += namelen;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册