git: 01fc488381e9 - main - nvme: Use strlcpy instead of strncpy to ensure termination

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Mon, 13 May 2024 19:04:19 UTC
The branch main has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=01fc488381e97c0bf589a297caa0c4b8e6b3e1c4

commit 01fc488381e97c0bf589a297caa0c4b8e6b3e1c4
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2024-05-13 19:03:49 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2024-05-13 19:03:49 +0000

    nvme: Use strlcpy instead of strncpy to ensure termination
    
    Reviewed by:    dab, imp
    Sponsored by:   Chelsio Communications
    Differential Revision:  https://reviews.freebsd.org/D45152
---
 sys/dev/nvme/nvme_sim.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/dev/nvme/nvme_sim.c b/sys/dev/nvme/nvme_sim.c
index f561756f99b7..2ba3df9ea6e8 100644
--- a/sys/dev/nvme/nvme_sim.c
+++ b/sys/dev/nvme/nvme_sim.c
@@ -203,7 +203,7 @@ nvme_sim_action(struct cam_sim *sim, union ccb *ccb)
 		cpi->xport_specific.nvme.slot = pci_get_slot(dev);
 		cpi->xport_specific.nvme.function = pci_get_function(dev);
 		cpi->xport_specific.nvme.extra = 0;
-		strncpy(cpi->xport_specific.nvme.dev_name, device_get_nameunit(dev),
+		strlcpy(cpi->xport_specific.nvme.dev_name, device_get_nameunit(dev),
 		    sizeof(cpi->xport_specific.nvme.dev_name));
 		cpi->hba_vendor = pci_get_vendor(dev);
 		cpi->hba_device = pci_get_device(dev);