[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20250617124546.24102-1-pranav.tyagi03@gmail.com>
Date: Tue, 17 Jun 2025 18:15:46 +0530
From: Pranav Tyagi <pranav.tyagi03@...il.com>
To: Carlos Maiolino <cem@...nel.org>
Cc: skhan@...uxfoundation.org,
linux-kernel-mentees@...ts.linux.dev,
linux-xfs@...r.kernel.org,
linux-kernel@...r.kernel.org,
Pranav Tyagi <pranav.tyagi03@...il.com>
Subject: [PATCH] fs/xfs: replace strncpy with strscpy
Replace the deprecated strncpy() with strscpy() as the destination
buffer should be NUL-terminated and does not require any trailing
NUL-padding. Also, since NUL-termination is guaranteed,
use sizeof(label) in place of XFSLABEL_MAX as the size
parameter.
Signed-off-by: Pranav Tyagi <pranav.tyagi03@...il.com>
---
fs/xfs/xfs_ioctl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index d250f7f74e3b..9f4d68c5b5ab 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -992,7 +992,7 @@ xfs_ioc_getlabel(
/* 1 larger than sb_fname, so this ensures a trailing NUL char */
memset(label, 0, sizeof(label));
spin_lock(&mp->m_sb_lock);
- strncpy(label, sbp->sb_fname, XFSLABEL_MAX);
+ strscpy(label, sbp->sb_fname, sizeof(label));
spin_unlock(&mp->m_sb_lock);
if (copy_to_user(user_label, label, sizeof(label)))
--
2.49.0
Powered by blists - more mailing lists