* [PATCH] xfs: Replace deprecated strncpy() with strscpy()
@ 2025-03-05 1:10 Thorsten Blum
2025-03-05 2:21 ` Darrick J. Wong
0 siblings, 1 reply; 3+ messages in thread
From: Thorsten Blum @ 2025-03-05 1:10 UTC (permalink / raw)
To: Carlos Maiolino, Darrick J. Wong
Cc: Thorsten Blum, linux-hardening, linux-xfs, linux-kernel
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.blum@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 */
compute_size:
context->count += prefix_len + namelen + 1;
--
2.48.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] xfs: Replace deprecated strncpy() with strscpy()
2025-03-05 1:10 [PATCH] xfs: Replace deprecated strncpy() with strscpy() Thorsten Blum
@ 2025-03-05 2:21 ` Darrick J. Wong
2025-03-05 2:59 ` Thorsten Blum
0 siblings, 1 reply; 3+ messages in thread
From: Darrick J. Wong @ 2025-03-05 2:21 UTC (permalink / raw)
To: Thorsten Blum; +Cc: Carlos Maiolino, linux-hardening, linux-xfs, linux-kernel
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.blum@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
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] xfs: Replace deprecated strncpy() with strscpy()
2025-03-05 2:21 ` Darrick J. Wong
@ 2025-03-05 2:59 ` Thorsten Blum
0 siblings, 0 replies; 3+ messages in thread
From: Thorsten Blum @ 2025-03-05 2:59 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: Carlos Maiolino, linux-hardening, linux-xfs, linux-kernel
On 5. Mar 2025, at 03:21, Darrick J. Wong wrote:
> 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.blum@linux.dev>
>> ---
>
> 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/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-03-05 2:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-05 1:10 [PATCH] xfs: Replace deprecated strncpy() with strscpy() Thorsten Blum
2025-03-05 2:21 ` Darrick J. Wong
2025-03-05 2:59 ` Thorsten Blum
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox