* [PATCH] ath6kl: replace deprecated strncpy with memcpy
@ 2023-10-13 21:19 Justin Stitt
2023-10-18 8:32 ` Kalle Valo
0 siblings, 1 reply; 2+ messages in thread
From: Justin Stitt @ 2023-10-13 21:19 UTC (permalink / raw
To: Kalle Valo; +Cc: linux-wireless, linux-kernel, linux-hardening, Justin Stitt
strncpy() is deprecated for use on NUL-terminated destination strings
[1] and as such we should prefer more robust and less ambiguous
interfaces.
The affected code's purpose is to truncate strings that are too long
with "..." like:
foobar -> fo...
The lengths have been carefully calculated and as such this has decayed
to a simple byte copy from one buffer to another -- let's use memcpy().
Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings [1]
Link: https://github.com/KSPP/linux/issues/90
Cc: linux-hardening@vger.kernel.org
Signed-off-by: Justin Stitt <justinstitt@google.com>
---
Note: build-tested only.
Found with: $ rg "strncpy\("
---
drivers/net/wireless/ath/ath6kl/init.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c
index 201e45554070..15f455adb860 100644
--- a/drivers/net/wireless/ath/ath6kl/init.c
+++ b/drivers/net/wireless/ath/ath6kl/init.c
@@ -1677,7 +1677,7 @@ static void ath6kl_init_get_fwcaps(struct ath6kl *ar, char *buf, size_t buf_len)
/* add "..." to the end of string */
trunc_len = strlen(trunc) + 1;
- strncpy(buf + buf_len - trunc_len, trunc, trunc_len);
+ memcpy(buf + buf_len - trunc_len, trunc, trunc_len);
return;
}
---
base-commit: cbf3a2cb156a2c911d8f38d8247814b4c07f49a2
change-id: 20231013-strncpy-drivers-net-wireless-ath-ath6kl-init-c-ffdb45d76eaf
Best regards,
--
Justin Stitt <justinstitt@google.com>
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ath6kl: replace deprecated strncpy with memcpy
2023-10-13 21:19 [PATCH] ath6kl: replace deprecated strncpy with memcpy Justin Stitt
@ 2023-10-18 8:32 ` Kalle Valo
0 siblings, 0 replies; 2+ messages in thread
From: Kalle Valo @ 2023-10-18 8:32 UTC (permalink / raw
To: Justin Stitt; +Cc: linux-wireless, linux-kernel, linux-hardening, Justin Stitt
Justin Stitt <justinstitt@google.com> wrote:
> strncpy() is deprecated for use on NUL-terminated destination strings
> [1] and as such we should prefer more robust and less ambiguous
> interfaces.
>
> The affected code's purpose is to truncate strings that are too long
> with "..." like:
> foobar -> fo...
>
> The lengths have been carefully calculated and as such this has decayed
> to a simple byte copy from one buffer to another -- let's use memcpy().
>
> Note: build-tested only.
>
> Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings [1]
> Link: https://github.com/KSPP/linux/issues/90
> Cc: linux-hardening@vger.kernel.org
> Signed-off-by: Justin Stitt <justinstitt@google.com>
> Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Patch applied to ath-next branch of ath.git, thanks.
40990961d983 wifi: ath6kl: replace deprecated strncpy with memcpy
--
https://patchwork.kernel.org/project/linux-wireless/patch/20231013-strncpy-drivers-net-wireless-ath-ath6kl-init-c-v1-1-d69c599b49a9@google.com/
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-10-18 8:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-13 21:19 [PATCH] ath6kl: replace deprecated strncpy with memcpy Justin Stitt
2023-10-18 8:32 ` Kalle Valo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).