From: Rahul Kumar <rk0006818@gmail.com>
To: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: linux-kernel-mentees@lists.linux.dev, skhan@linuxfoundation.org,
rk0006818@gmail.com
Subject: [PATCH] wireless/ti/wl1251: Replace strncpy with strscpy in fw_version
Date: Tue, 9 Sep 2025 16:38:41 +0530 [thread overview]
Message-ID: <20250909110841.2904546-1-rk0006818@gmail.com> (raw)
strncpy is deprecated for use on NUL-terminated strings, as documented in
Documentation/process/deprecated.rst. It NUL-pads the destination buffer
and does not guarantee NUL termination if the source string is longer
than the copy length
This patch replaces the existing strncpy() and manual NUL termination with
strscpy(), which ensures safe copying and automatic NUL termination.
Signed-off-by: Rahul Kumar <rk0006818@gmail.com>
---
drivers/net/wireless/ti/wl1251/acx.c | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)
diff --git a/drivers/net/wireless/ti/wl1251/acx.c b/drivers/net/wireless/ti/wl1251/acx.c
index f78fc3880423..73232f7e92d1 100644
--- a/drivers/net/wireless/ti/wl1251/acx.c
+++ b/drivers/net/wireless/ti/wl1251/acx.c
@@ -149,15 +149,8 @@ int wl1251_acx_fw_version(struct wl1251 *wl, char *buf, size_t len)
goto out;
}
- /* be careful with the buffer sizes */
- strncpy(buf, rev->fw_version, min(len, sizeof(rev->fw_version)));
-
- /*
- * if the firmware version string is exactly
- * sizeof(rev->fw_version) long or fw_len is less than
- * sizeof(rev->fw_version) it won't be null terminated
- */
- buf[min(len, sizeof(rev->fw_version)) - 1] = '\0';
+ /* copy firmware version safely, strscpy ensures NUL termination */
+ strscpy(buf, rev->fw_version, min(len, sizeof(rev->fw_version)));
out:
kfree(rev);
--
2.43.0
reply other threads:[~2025-09-09 11:09 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250909110841.2904546-1-rk0006818@gmail.com \
--to=rk0006818@gmail.com \
--cc=linux-kernel-mentees@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=skhan@linuxfoundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox