Fix ATS lenght in pn53x_decode_target_data().

This commit is contained in:
Romuald Conty 2010-05-18 10:55:18 +00:00
parent 8c1815fbea
commit cf0c2dd9f2

View file

@ -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;