projects
/
linux-2.6-microblaze.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
2470975
)
wifi: ath6kl: replace deprecated strncpy with memcpy
author
Justin Stitt
<justinstitt@google.com>
Fri, 13 Oct 2023 21:19:02 +0000
(21:19 +0000)
committer
Kalle Valo
<quic_kvalo@quicinc.com>
Wed, 18 Oct 2023 08:32:36 +0000
(11:32 +0300)
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
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>
Link:
https://lore.kernel.org/r/20231013-strncpy-drivers-net-wireless-ath-ath6kl-init-c-v1-1-d69c599b49a9@google.com
drivers/net/wireless/ath/ath6kl/init.c
patch
|
blob
|
history
diff --git
a/drivers/net/wireless/ath/ath6kl/init.c
b/drivers/net/wireless/ath/ath6kl/init.c
index
201e455
..
15f455a
100644
(file)
--- 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;
-
strn
cpy(buf + buf_len - trunc_len, trunc, trunc_len);
+
mem
cpy(buf + buf_len - trunc_len, trunc, trunc_len);
return;
}