* [PATCH] nvmet: replace strncpy with strscpy
@ 2025-04-01 0:47 Marcelo Moreira
2025-04-03 4:27 ` Christoph Hellwig
0 siblings, 1 reply; 2+ messages in thread
From: Marcelo Moreira @ 2025-04-01 0:47 UTC (permalink / raw)
To: linux-nvme, hch, sagi, kch, skhan, linux-kernel-mentees,
~lkcamp/patches
strncpy() is deprecated due to its lack of NULL-termination
guarantees and unnecessary zero-padding of the destination buffer.
Use strscpy() instead.
Link: https://github.com/KSPP/linux/issues/90
Signed-off-by: Marcelo Moreira <marcelomoreira1905@gmail.com>
---
drivers/nvme/target/discovery.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/nvme/target/discovery.c b/drivers/nvme/target/discovery.c
index df7207640506..c06f3e04296c 100644
--- a/drivers/nvme/target/discovery.c
+++ b/drivers/nvme/target/discovery.c
@@ -119,7 +119,7 @@ static void nvmet_format_discovery_entry(struct nvmf_disc_rsp_page_hdr *hdr,
memcpy(e->trsvcid, port->disc_addr.trsvcid, NVMF_TRSVCID_SIZE);
memcpy(e->traddr, traddr, NVMF_TRADDR_SIZE);
memcpy(e->tsas.common, port->disc_addr.tsas.common, NVMF_TSAS_SIZE);
- strncpy(e->subnqn, subsys_nqn, NVMF_NQN_SIZE);
+ strscpy(e->subnqn, subsys_nqn, NVMF_NQN_SIZE);
}
/*
--
2.49.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] nvmet: replace strncpy with strscpy
2025-04-01 0:47 [PATCH] nvmet: replace strncpy with strscpy Marcelo Moreira
@ 2025-04-03 4:27 ` Christoph Hellwig
0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2025-04-03 4:27 UTC (permalink / raw)
To: Marcelo Moreira
Cc: linux-nvme, hch, sagi, kch, skhan, linux-kernel-mentees,
~lkcamp/patches
On Mon, Mar 31, 2025 at 09:47:28PM -0300, Marcelo Moreira wrote:
> strncpy() is deprecated due to its lack of NULL-termination
> guarantees and unnecessary zero-padding of the destination buffer.
> Use strscpy() instead.
Nothing explains here why it is deprecated and why the replacement
is better. And why using memcpy or a seq_buf wasn't considered.
> Link: https://github.com/KSPP/linux/issues/90
And these kinds of links are actively harmful as the point a
commercial entity that can be taken down or changed at any time.
Don't do that.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-04-03 4:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-01 0:47 [PATCH] nvmet: replace strncpy with strscpy Marcelo Moreira
2025-04-03 4:27 ` Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox