diff --git a/libnfc/chips/pn53x.c b/libnfc/chips/pn53x.c index 8d28cd1..5e6d91d 100644 --- a/libnfc/chips/pn53x.c +++ b/libnfc/chips/pn53x.c @@ -243,7 +243,8 @@ pn53x_decode_target_data(const byte_t* pbtRawData, size_t szDataLen, nfc_chip_t switch(ntt) { case NTT_MIFARE: case NTT_GENERIC_PASSIVE_106: - // We skip target number (Tg) + // We skip the first byte: its the target number (Tg) + pbtRawData++; // Somehow they switched the lower and upper ATQA bytes around for the PN531 chipset if (nc == NC_PN531) { @@ -261,7 +262,7 @@ pn53x_decode_target_data(const byte_t* pbtRawData, size_t szDataLen, nfc_chip_t // Did we received an optional ATS (Smardcard ATR) if (szDataLen > (pnti->nai.szUidLen + 5)) { - pnti->nai.szAtsLen = *(pbtRawData++); + pnti->nai.szAtsLen = ((*(pbtRawData++)) - 1); // In pbtRawData, ATS Length byte is counted in ATS Frame. memcpy(pnti->nai.abtAts, pbtRawData, pnti->nai.szAtsLen); } else { pnti->nai.szAtsLen = 0;