On Wed, Mar 05, 2025 at 02:10:21AM +0100, Thorsten Blum wrote: > strncpy() is deprecated for NUL-terminated destination buffers. Use > strscpy() instead and remove the manual NUL-termination. > > No functional changes intended. > > Link: https://github.com/KSPP/linux/issues/90 > Cc: linux-hardening@vger.kernel.org > Signed-off-by: Thorsten Blum <thorsten.b...@linux.dev> > --- > fs/xfs/xfs_xattr.c | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > > diff --git a/fs/xfs/xfs_xattr.c b/fs/xfs/xfs_xattr.c > index 0f641a9091ec..9f9a866ab803 100644 > --- a/fs/xfs/xfs_xattr.c > +++ b/fs/xfs/xfs_xattr.c > @@ -243,9 +243,7 @@ __xfs_xattr_put_listent( > offset = context->buffer + context->count; > memcpy(offset, prefix, prefix_len); > offset += prefix_len; > - strncpy(offset, (char *)name, namelen); /* real name */ > - offset += namelen; > - *offset = '\0'; > + strscpy(offset, (char *)name, namelen + 1); /* real name */
Please read the list archives before you post: https://lore.kernel.org/linux-xfs/20230211050641.GA2118932@ceph-admin/ If anything, memcpy() would be appropriate here. --D > > compute_size: > context->count += prefix_len + namelen + 1; > -- > 2.48.1 >