Skip to content

Commit fd5beaf

Browse files
author
Darrick J. Wong
committed
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 <[email protected]> Reviewed-by: Gao Xiang <[email protected]> Reviewed-by: Dave Chinner <[email protected]>
1 parent 032e160 commit fd5beaf

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/xfs/xfs_xattr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ __xfs_xattr_put_listent(
210210
return;
211211
}
212212
offset = context->buffer + context->count;
213-
strncpy(offset, prefix, prefix_len);
213+
memcpy(offset, prefix, prefix_len);
214214
offset += prefix_len;
215215
strncpy(offset, (char *)name, namelen); /* real name */
216216
offset += namelen;

0 commit comments

Comments
 (0)