Skip to contentSkip to conversation

net/smc: replace strncpy with strscpy

PATCH Applied Pranav Tyagi 3 participants 3 messages Jun 20, 2025 – Jun 24, 2025

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

PATCH v2 1/1 net/smc: replace strncpy with strscpy

Replace the deprecated strncpy() with two-argument version of strscpy() as the destination is an array
and should be NUL-terminated.

---
 net/smc/smc_pnet.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/smc/smc_pnet.c +1 -1
index b391c2ef463f..76ad29e31d60 100644
@@ -370,7 +370,7 @@ static int smc_pnet_add_eth(struct smc_pnettable *pnettable, struct net *net,
 		goto out_put;
 	new_pe->type = SMC_PNET_ETH;
 	memcpy(new_pe->pnet_name, pnet_name, SMC_MAX_PNETID_LEN);
-	strncpy(new_pe->eth_name, eth_name, IFNAMSIZ);
+	strscpy(new_pe->eth_name, eth_name);
 	rc = -EEXIST;
 	new_netdev = true;
 	mutex_lock(&pnettable->lock);
Signature · 1 line
2.49.0
#2 lore raw
In reply to Pranav Tyagi
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 8 lines · On Fri, 20 Jun 2025 15:55:59 +0530 you wrote:

Replace the deprecated strncpy() with two-argument version of strscpy() as the destination is an array
and should be NUL-terminated.

---
 net/smc/smc_pnet.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Here is the summary with links:
- [v2] net/smc: replace strncpy with strscpy

    https://git.kernel.org/netdev/net-next/c/ae2402bf882b

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html