wireless/ti/wl1251: Replace strncpy with strscpy in fw_version
PATCH 1/1 wireless/ti/wl1251: Replace strncpy with strscpy in fw_version
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 <[email protected]>
--- drivers/net/wireless/ti/wl1251/acx.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)
drivers/net/wireless/ti/wl1251/acx.c +2 -9
@@ -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);
Signature · 1 line
2.43.0