[PATCH v2] net/smc: replace strncpy with strscpy

Pranav Tyagi posted 1 patch 3 months, 2 weeks ago
net/smc/smc_pnet.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH v2] net/smc: replace strncpy with strscpy
Posted by Pranav Tyagi 3 months, 2 weeks ago
Replace the deprecated strncpy() with two-argument version of
strscpy() as the destination is an array
and should be NUL-terminated.

Signed-off-by: Pranav Tyagi <pranav.tyagi03@gmail.com>
---
 net/smc/smc_pnet.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/smc/smc_pnet.c b/net/smc/smc_pnet.c
index b391c2ef463f..76ad29e31d60 100644
--- a/net/smc/smc_pnet.c
+++ b/net/smc/smc_pnet.c
@@ -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);
-- 
2.49.0
Re: [PATCH v2] net/smc: replace strncpy with strscpy
Posted by Simon Horman 3 months, 2 weeks ago
On Fri, Jun 20, 2025 at 03:55:59PM +0530, Pranav Tyagi wrote:
> Replace the deprecated strncpy() with two-argument version of
> strscpy() as the destination is an array
> and should be NUL-terminated.
> 
> Signed-off-by: Pranav Tyagi <pranav.tyagi03@gmail.com>

Thanks for the update.

Reviewed-by: Simon Horman <horms@kernel.org>