xfs: Replace deprecated strncpy() with strscpy()
PATCH 1/1 xfs: Replace deprecated strncpy() with strscpy()
strncpy() is deprecated for NUL-terminated destination buffers. Use strscpy() instead and remove the manual NUL-termination.
No functional changes intended.
--- fs/xfs/xfs_xattr.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
fs/xfs/xfs_xattr.c +1 -3
@@ -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 */ compute_size: context->count += prefix_len + namelen +1 ;
Signature · 1 line
2.48.1
Quoted 17 lines · Thorsten Blum
strncpy()is deprecated for NUL-terminated destination buffers. Usestrscpy()instead and remove the manual NUL-termination.No functional changes intended.
Signed-off-by Thorsten Blum <[email protected]>--- fs/xfs/xfs_xattr.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)fs/xfs/xfs_xattr.c +0
-0
fs/xfs/xfs_xattr.c __xfs_xattr_put_listent( · line 246
Quoted 7 lines
fs/xfs/xfs_xattr.c +1
-3@@ -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
Quoted 6 lines
fs/xfs/xfs_xattr.c +0
-0compute_size: context->count += prefix_len + namelen +1 ;Signature · 1 line
2.48.1
Quoted 6 lines · Darrick J. Wong
Quoted 5 lines · Thorsten Blum
strncpy()is deprecated for NUL-terminated destination buffers. Usestrscpy()instead and remove the manual NUL-termination.No functional changes intended.
Quoted 7 lines
Quoted 4 lines
Signed-off-by Thorsten Blum <[email protected]>---
Please read the list archives before you post:
https://lore.kernel.org/linux-xfs/20230211050641.GA2118932@ceph-admin/
My bad, I found [1] and saw that you reviewed it, but missed Li's reply.
[1] https://lore.kernel.org/linux-kernel/Y9sKXhxvf0DDusih@magnolia/
[2] https://lore.kernel.org/linux-xfs/20230211050641.GA2118932@ceph-admin/