From b8d65f9b27ea7e8db4389750b746f7945d763072 Mon Sep 17 00:00:00 2001 From: Romuald Conty Date: Wed, 6 Oct 2010 17:52:15 +0000 Subject: [PATCH] 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. --- libnfc/drivers/acr122.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/libnfc/drivers/acr122.c b/libnfc/drivers/acr122.c index d21c8b6..ca42e16 100644 --- a/libnfc/drivers/acr122.c +++ b/libnfc/drivers/acr122.c @@ -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