svn commit: r367997 - head/sys/cam/mmc

Jung-uk Kim jkim at FreeBSD.org
Tue Nov 24 21:14:37 UTC 2020


Author: jkim
Date: Tue Nov 24 21:14:36 2020
New Revision: 367997
URL: https://svnweb.freebsd.org/changeset/base/367997

Log:
  Do not truncate the last character from serial number.
  
  strlcpy() requires one more byte for the NULL character.
  
  Submitted by:	Henri Hennebert (hlh at restart dot be)
  MFC after:	3 days

Modified:
  head/sys/cam/mmc/mmc_da.c

Modified: head/sys/cam/mmc/mmc_da.c
==============================================================================
--- head/sys/cam/mmc/mmc_da.c	Tue Nov 24 19:55:01 2020	(r367996)
+++ head/sys/cam/mmc/mmc_da.c	Tue Nov 24 21:14:36 2020	(r367997)
@@ -1306,12 +1306,12 @@ sdda_start_init(void *context, union ccb *start_ccb)
 	device->serial_num_len = strlen(softc->card_sn_string);
 	device->serial_num = (u_int8_t *)malloc((device->serial_num_len + 1),
 	    M_CAMXPT, M_NOWAIT);
-	strlcpy(device->serial_num, softc->card_sn_string, device->serial_num_len);
+	strlcpy(device->serial_num, softc->card_sn_string, device->serial_num_len + 1);
 
 	device->device_id_len = strlen(softc->card_id_string);
 	device->device_id = (u_int8_t *)malloc((device->device_id_len + 1),
 	    M_CAMXPT, M_NOWAIT);
-	strlcpy(device->device_id, softc->card_id_string, device->device_id_len);
+	strlcpy(device->device_id, softc->card_id_string, device->device_id_len + 1);
 
 	strlcpy(mmcp->model, softc->card_id_string, sizeof(mmcp->model));
 


More information about the svn-src-head mailing list