From 5a6bb0bbc51bdb2e0bfd9d7a5fb92c65cc3346d4 Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Wed, 20 Oct 2010 18:11:06 +0000 Subject: [PATCH] examples: mifare.c fix potential bug when used in non-EasyFraming environment --- examples/mifare.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/examples/mifare.c b/examples/mifare.c index f5bf66b..4d63dd8 100644 --- a/examples/mifare.c +++ b/examples/mifare.c @@ -24,6 +24,7 @@ nfc_initiator_mifare_cmd (nfc_device_t * pnd, const mifare_cmd mc, const uint8_t size_t szRx; size_t szParamLen; byte_t abtCmd[265]; + bool bEasyFraming; // Make sure we are dealing with a active device if (!pnd->bActive) @@ -67,12 +68,23 @@ nfc_initiator_mifare_cmd (nfc_device_t * pnd, const mifare_cmd mc, const uint8_t if (szParamLen) memcpy (abtCmd + 2, (byte_t *) pmp, szParamLen); + bEasyFraming = pnd->bEasyFraming; + if (!nfc_configure (pnd, NDO_EASY_FRAMING, true)) { + nfc_perror (pnd, "nfc_configure"); + return false; + } // Fire the mifare command if (!nfc_initiator_transceive_bytes (pnd, abtCmd, 2 + szParamLen, abtRx, &szRx)) { if (pnd->iLastError != 0x14) nfc_perror (pnd, "nfc_initiator_transceive_bytes"); + nfc_configure (pnd, NDO_EASY_FRAMING, bEasyFraming); return false; } + if (!nfc_configure (pnd, NDO_EASY_FRAMING, bEasyFraming)) { + nfc_perror (pnd, "nfc_configure"); + return false; + } + // When we have executed a read command, copy the received bytes into the param if (mc == MC_READ) { if (szRx == 16) {