Skip to contentSkip to conversation

brcm80211: use strscpy() to instead of strncpy()

PATCH In review [email protected] 3 participants 4 messages Dec 23, 2022 – Jan 16, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 brcm80211: use strscpy() to instead of strncpy()

From: Xu Panda <[email protected]>

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

---
 drivers/net/wireless/broadcom/brcm80211/brcmsmac/dma.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/wireless/broadcom/brcm80211/brcmsmac/dma.c +1 -2
index b7df576bb84d..66336c87b0d9 100644
@@ -584,8 +584,7 @@ struct dma_pub *dma_attach(char *name, struct brcms_c_info *wlc,
 		      rxextheadroom, nrxpost, rxoffset, txregbase, rxregbase);
 
 	/* make a private copy of our callers name */
-	strncpy(di->name, name, MAXNAMEL);
-	di->name[MAXNAMEL - 1] = '\0';
+	strscpy(di->name, name, MAXNAMEL);
 
 	di->dmadev = core->dma_dev;
 
Signature · 1 line
2.15.2
#1 lore raw
Quoted 7 lines · <[email protected]> wrote:

From: Xu Panda <[email protected]>

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

Mismatch email in From and Signed-off-by lines:

From: <[email protected]>

Patch set to Changes Requested.

Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
#2 lore raw
Quoted 10 lines · Kalle Valo
Quoted 7 lines · <[email protected]> wrote:

From: Xu Panda <[email protected]>

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

Quoted 6 lines

Mismatch email in From and Signed-off-by lines:

From: <[email protected]>

Patch set to Changes Requested.

Kalle, please be aware of this response
https://lore.kernel.org/netdev/[email protected]/

"I don't trust that you know what you're doing. So please don't send any more strncpy() -> strscpy() conversions for networking."

Thanks

Quoted 6 lines
Signature · 4 lines
-- 
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
#3 lore raw
Quoted 16 lines · Leon Romanovsky
Quoted 15 lines · Kalle Valo
Quoted 7 lines · <[email protected]> wrote:

From: Xu Panda <[email protected]>

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

Mismatch email in From and Signed-off-by lines:

From: <[email protected]>

Quoted 7 lines
Quoted 1 line

Patch set to Changes Requested.

Kalle, please be aware of this response
https://lore.kernel.org/netdev/[email protected]/

"I don't trust that you know what you're doing. So please don't send any more strncpy() -> strscpy() conversions for networking."

Good to know, thanks.

Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/list/

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