sc-hsm: Fixed memory checking and removed warning

This commit is contained in:
Andreas Schwier 2013-08-29 11:18:44 +02:00
parent f09dae493c
commit 4604dac3a7
1 changed files with 4 additions and 3 deletions

View File

@ -607,9 +607,10 @@ static int sc_hsm_get_serialnr(sc_card_t *card, sc_serial_number_t *serial)
}
serial->len = strlen(priv->serialno);
/* FIXME the length to copy should be dependant on the size of
* serial->value *and* priv->serialno */
strncpy(serial->value, priv->serialno, sizeof(serial->value));
if (serial->len > sizeof(serial->value))
serial->len = sizeof(serial->value);
memcpy(serial->value, priv->serialno, serial->len);
LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
}