Skip to contentSkip to conversation

rtl8187: Fix warning generated when strncpy() destination length matches the sixe argument

PATCH In review Larry Finger 2 participants 2 messages Aug 20, 2018 – Aug 31, 2018 RTL8187 wireless driver

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rtl8187: Fix warning generated when strncpy() destination length matches the sixe argument

In gcc8, when the 3rd argument (size) of a call to strncpy() matches the length of the first argument, the compiler warns of the possibility of an unterminated string. Using strlcpy() forces a null at the end.

---
 drivers/net/wireless/realtek/rtl818x/rtl8187/leds.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/realtek/rtl818x/rtl8187/leds.c +1 -1
index c2d5b495c179..c089540116fa 100644
@@ -146,7 +146,7 @@ static int rtl8187_register_led(struct ieee80211_hw *dev,
 	led->dev = dev;
 	led->ledpin = ledpin;
 	led->is_radio = is_radio;
-	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;
Signature · 1 line
2.18.0
#1 lore raw
Quoted 5 lines · Larry Finger

In gcc8, when the 3rd argument (size) of a call to strncpy() matches the length of the first argument, the compiler warns of the possibility of an unterminated string. Using strlcpy() forces a null at the end.

Patch applied to wireless-drivers-next.git, thanks.

199ba9faca90 rtl8187: Fix warning generated when strncpy() destination length matches the sixe argument

Signature · 3 lines
https://patchwork.kernel.org/patch/10570639/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches