diff --git a/NEWS b/NEWS index e52b5b7..0c20042 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,9 @@ -Changes between 0.2.3 and 0.3.0 [XX xxx XXXX] +Changes between 0.3.0 and 0.3.1 [XX xxx XXXX] + + *) Fix mifare_classic_transfer() for devices returning a 1 byte response on + success. + +Changes between 0.2.3 and 0.3.0 [23 dec 2010] *) Add support for ISO and AES authentication through mifare_desfire_authenticate_iso() and mifare_desfire_authenticate_aes(). diff --git a/libfreefare/mifare_classic.c b/libfreefare/mifare_classic.c index 6a6afa6..308f82d 100644 --- a/libfreefare/mifare_classic.c +++ b/libfreefare/mifare_classic.c @@ -72,6 +72,8 @@ #include #include "freefare_internal.h" +#define MC_OK 0x0A + #define MC_AUTH_A 0x60 #define MC_AUTH_B 0x61 #define MC_READ 0x30 @@ -478,7 +480,16 @@ mifare_classic_transfer (MifareTag tag, const MifareClassicBlockNumber block) CLASSIC_TRANSCEIVE (tag, cmd, res); - return (BUFFER_SIZE (res) == 0) ? 0 : res[0]; + /* + * Depending on the device we are using, on success, the TRANSFER command + * returns either no data (e.g. touchatag) or a 1 byte response, 0x0A, + * meaning that the action was performed correctly (e.g. Snapper Feeder, + * SCL 3711). + */ + if (!BUFFER_SIZE (res) || ((BUFFER_SIZE (res) == 1) && (res[0] = MC_OK))) + return 0; + else + return res[0]; }