nvmet: replace strncpy with strscpy
Subsystems (2)
PATCH 1/1 nvmet: replace strncpy with strscpy
strncpy() is deprecated due to its lack of NULL-termination guarantees and unnecessary zero-padding of the destination buffer. Use strscpy() instead.
Signed-off-by Marcelo Moreira <[email protected]>
--- drivers/nvme/target/discovery.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/target/discovery.c +1 -1
@@ -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 ); }/*
Signature · 1 line
2.49.0
Christoph Hellwig
maintainerQuoted 3 lines · Marcelo Moreira
strncpy()is deprecated due to its lack of NULL-termination guarantees and unnecessary zero-padding of the destination buffer. Usestrscpy()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.
Quoted 1 line
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.