Keep the last byte as \0 to be sure abtFw will be null-terminated. Fixes an issue I have with my ACR122U205: the last char of the firmware string was changing each nfc-list launch.

This commit is contained in:
Romuald Conty 2010-10-06 17:52:15 +00:00
parent d9505bbbcc
commit b8d65f9b27

View file

@ -350,13 +350,9 @@ acr122_firmware (const nfc_device_spec_t nds)
size_t szFwLen = sizeof (abtFw);
memset (abtFw, 0x00, szFwLen);
if (pas->ioCard.dwProtocol == SCARD_PROTOCOL_UNDEFINED) {
uiResult =
SCardControl (pas->hCard, IOCTL_CCID_ESCAPE_SCARD_CTL_CODE, abtGetFw, sizeof (abtGetFw), abtFw, szFwLen,
(void *) &szFwLen);
uiResult = SCardControl (pas->hCard, IOCTL_CCID_ESCAPE_SCARD_CTL_CODE, abtGetFw, sizeof (abtGetFw), abtFw, szFwLen-1, (void *) &szFwLen);
} else {
uiResult =
SCardTransmit (pas->hCard, &(pas->ioCard), abtGetFw, sizeof (abtGetFw), NULL, (byte_t *) abtFw,
(void *) &szFwLen);
uiResult = SCardTransmit (pas->hCard, &(pas->ioCard), abtGetFw, sizeof (abtGetFw), NULL, (byte_t *) abtFw, (void *) &szFwLen);
}
#ifdef DEBUG