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 --- 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