All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] ath5k: use strscpy() to instead of strncpy()
@ 2022-12-23  2:34 yang.yang29
  2022-12-23 15:02 ` Luis Chamberlain
  0 siblings, 1 reply; 3+ messages in thread
From: yang.yang29 @ 2022-12-23  2:34 UTC (permalink / raw)
  To: jirislaby
  Cc: mickflemm, mcgrof, kvalo, davem, edumazet, kuba, pabeni,
	linux-wireless, netdev, linux-kernel, xu.panda, yang.yang29

From: Xu Panda <xu.panda@zte.com.cn>

The implementation of strscpy() is more robust and safer.
That's now the recommended way to copy NUL-terminated strings.

Signed-off-by: Xu Panda <xu.panda@zte.com.cn>
Signed-off-by: Yang Yang <yang.yang29@zte.com>
---
 drivers/net/wireless/ath/ath5k/led.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath5k/led.c b/drivers/net/wireless/ath/ath5k/led.c
index 33e9928af363..439052984796 100644
--- a/drivers/net/wireless/ath/ath5k/led.c
+++ b/drivers/net/wireless/ath/ath5k/led.c
@@ -131,8 +131,7 @@ ath5k_register_led(struct ath5k_hw *ah, struct ath5k_led *led,
 	int err;

 	led->ah = ah;
-	strncpy(led->name, name, sizeof(led->name));
-	led->name[sizeof(led->name)-1] = 0;
+	strscpy(led->name, name, sizeof(led->name));
 	led->led_dev.name = led->name;
 	led->led_dev.default_trigger = trigger;
 	led->led_dev.brightness_set = ath5k_led_brightness_set;
-- 
2.15.2

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-12-24  2:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-23  2:34 [PATCH net-next] ath5k: use strscpy() to instead of strncpy() yang.yang29
2022-12-23 15:02 ` Luis Chamberlain
2022-12-24  2:47   ` yang.yang29

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.