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
This commit is contained in:
jkim 2020-11-24 21:14:36 +00:00
parent 300518aea9
commit 5704517b52

View File

@ -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));