Discussion:
b43legacy/leds: Ensure NUL-termination of LED name string
Michael Büsch
2018-07-31 19:14:16 UTC
Permalink
strncpy might not NUL-terminate the string, if the name equals the buffer size.
Use strlcpy instead.

Signed-off-by: Michael Buesch <***@bues.ch>
Cc: ***@vger.kernel.org
---
drivers/net/wireless/broadcom/b43legacy/leds.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/broadcom/b43legacy/leds.c b/drivers/net/wireless/broadcom/b43legacy/leds.c
index fd4565389c77..bc922118b6ac 100644
--- a/drivers/net/wireless/broadcom/b43legacy/leds.c
+++ b/drivers/net/wireless/broadcom/b43legacy/leds.c
@@ -101,7 +101,7 @@ static int b43legacy_register_led(struct b43legacy_wldev *dev,
led->dev = dev;
led->index = led_index;
led->activelow = activelow;
- strncpy(led->name, name, sizeof(led->name));
+ strlcpy(led->name, name, sizeof(led->name));

led->led_dev.name = led->name;
led->led_dev.default_trigger = default_trigger;
--
Michael
Kalle Valo
2018-08-09 15:45:22 UTC
Permalink
Post by Michael Büsch
strncpy might not NUL-terminate the string, if the name equals the buffer size.
Use strlcpy instead.
Applied manually:

4d77a89e3924 b43legacy/leds: Ensure NUL-termination of LED name string
--
Kalle Valo
Loading...