On 6/27/25 03:21, Andriy Gapon wrote:
The branch main has been updated by avg:

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

commit ad8d33679999c0e7f6fd2b77d2e414102bd365ec
Author:     Andriy Gapon <a...@freebsd.org>
AuthorDate: 2025-06-23 21:31:04 +0000
Commit:     Andriy Gapon <a...@freebsd.org>
CommitDate: 2025-06-27 07:13:34 +0000

     mmc_xpt: use strlcpy instead of strncpy
A better practice in general. MFC after: 1 week
---
  sys/cam/mmc/mmc_xpt.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/sys/cam/mmc/mmc_xpt.c b/sys/cam/mmc/mmc_xpt.c
index 138f96eaaa49..4fce03004994 100644
--- a/sys/cam/mmc/mmc_xpt.c
+++ b/sys/cam/mmc/mmc_xpt.c
@@ -1213,9 +1213,9 @@ mmc_path_inq(struct ccb_pathinq *cpi, const char *hba,
        cpi->max_lun = 0;
        cpi->initiator_id = 1;
        cpi->maxio = maxio;
-       strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN);
-       strncpy(cpi->hba_vid, hba, HBA_IDLEN);
-       strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN);
+       strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN);
+       strlcpy(cpi->hba_vid, hba, HBA_IDLEN);
+       strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN);
        cpi->unit_number = cam_sim_unit(sim);
        cpi->bus_id = cam_sim_bus(sim);
        cpi->protocol = PROTO_MMCSD;

Hmm, are you sure these aren't depending on strncpy zero-padding
the result out to the full length?  String fields in inquiry/identity
structures are often not C strings but have other requirements.
(Some of them are space padded instead of \0 padded for example.)

--
John Baldwin


Reply via email to