* [PATCH] net/smc: Replace use of strncpy on NUL-terminated string with strscpy
@ 2025-08-31 9:49 James Flowers
2025-08-31 10:17 ` James
0 siblings, 1 reply; 2+ messages in thread
From: James Flowers @ 2025-08-31 9:49 UTC (permalink / raw)
To: alibuda, dust.li, sidraya, wenjia, mjambigi, tonylu, guwen, davem,
edumazet, kuba, pabeni, horms, skhan
Cc: James Flowers, linux-rdma, linux-s390, netdev, linux-kernel,
linux-kernel-mentees
strncpy is deprecated for use on NUL-terminated strings, as indicated in
Documentation/process/deprecated.rst. strncpy NUL-pads the destination
buffer and doesn't guarantee the destination buffer will be NUL
terminated.
Signed-off-by: James Flowers <bold.zone2373@fastmail.com>
---
Note: this has only been compile tested.
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 76ad29e31d60..5cfde2b9cad8 100644
--- a/net/smc/smc_pnet.c
+++ b/net/smc/smc_pnet.c
@@ -450,7 +450,7 @@ static int smc_pnet_add_ib(struct smc_pnettable *pnettable, char *ib_name,
return -ENOMEM;
new_pe->type = SMC_PNET_IB;
memcpy(new_pe->pnet_name, pnet_name, SMC_MAX_PNETID_LEN);
- strncpy(new_pe->ib_name, ib_name, IB_DEVICE_NAME_MAX);
+ strscpy(new_pe->ib_name, ib_name, IB_DEVICE_NAME_MAX);
new_pe->ib_port = ib_port;
new_ibdev = true;
--
2.50.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] net/smc: Replace use of strncpy on NUL-terminated string with strscpy
2025-08-31 9:49 [PATCH] net/smc: Replace use of strncpy on NUL-terminated string with strscpy James Flowers
@ 2025-08-31 10:17 ` James
0 siblings, 0 replies; 2+ messages in thread
From: James @ 2025-08-31 10:17 UTC (permalink / raw)
To: alibuda, dust.li, sidraya, wenjia, mjambigi, tonylu, guwen, davem,
edumazet, kuba, pabeni, horms, Shuah Khan
Cc: linux-rdma, linux-s390, netdev, linux-kernel,
linux-kernel-mentees
On Sun, Aug 31, 2025, at 2:49 AM, James Flowers wrote:
> strncpy is deprecated for use on NUL-terminated strings, as indicated in
> Documentation/process/deprecated.rst. strncpy NUL-pads the destination
> buffer and doesn't guarantee the destination buffer will be NUL
> terminated.
>
> Signed-off-by: James Flowers <bold.zone2373@fastmail.com>
> ---
> Note: this has only been compile tested.
>
> 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 76ad29e31d60..5cfde2b9cad8 100644
> --- a/net/smc/smc_pnet.c
> +++ b/net/smc/smc_pnet.c
> @@ -450,7 +450,7 @@ static int smc_pnet_add_ib(struct smc_pnettable
> *pnettable, char *ib_name,
> return -ENOMEM;
> new_pe->type = SMC_PNET_IB;
> memcpy(new_pe->pnet_name, pnet_name, SMC_MAX_PNETID_LEN);
> - strncpy(new_pe->ib_name, ib_name, IB_DEVICE_NAME_MAX);
> + strscpy(new_pe->ib_name, ib_name, IB_DEVICE_NAME_MAX);
> new_pe->ib_port = ib_port;
>
> new_ibdev = true;
> --
> 2.50.1
Please disregard. Sorry, just noticed I should have used the two argument version of strscpy. I will send a V2.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-08-31 10:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-31 9:49 [PATCH] net/smc: Replace use of strncpy on NUL-terminated string with strscpy James Flowers
2025-08-31 10:17 ` James
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).