From 7dd1053d03e378d3a6df1d1bdb2997761f61abed Mon Sep 17 00:00:00 2001 From: Romuald Conty Date: Fri, 23 Jul 2010 12:45:21 +0000 Subject: [PATCH] Fix incorrect selected targets size in pn53x_InListPassive(). --- libnfc/chips/pn53x.c | 4 ++-- libnfc/chips/pn53x.h | 4 +++- libnfc/nfc.c | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/libnfc/chips/pn53x.c b/libnfc/chips/pn53x.c index 3d99aaf..2d5e810 100644 --- a/libnfc/chips/pn53x.c +++ b/libnfc/chips/pn53x.c @@ -279,7 +279,7 @@ bool pn53x_InListPassiveTarget(const nfc_device_t* pnd, const nfc_modulation_t nmInitModulation, const byte_t szMaxTargets, const byte_t* pbtInitiatorData, const size_t szInitiatorDataLen, - size_t* pszTargets, byte_t* pbtTargetsData, size_t* pszTargetsData) + byte_t* pbtTargetsData, size_t* pszTargetsData) { byte_t abtCmd[sizeof(pncmd_initiator_list_passive)]; memcpy(abtCmd,pncmd_initiator_list_passive,sizeof(pncmd_initiator_list_passive)); @@ -294,7 +294,7 @@ pn53x_InListPassiveTarget(const nfc_device_t* pnd, size_t szRxLen = MAX_FRAME_LEN; // We can not use pn53x_transceive() because abtRx[0] gives no status info if(pnd->pdc->transceive(pnd->nds,abtCmd,4+szInitiatorDataLen,pbtTargetsData,&szRxLen)) { - *pszTargetsData = szRxLen; + *pszTargetsData = pbtTargetsData[0]; return true; } else { return false; diff --git a/libnfc/chips/pn53x.h b/libnfc/chips/pn53x.h index b1f59ff..804ec0e 100644 --- a/libnfc/chips/pn53x.h +++ b/libnfc/chips/pn53x.h @@ -77,6 +77,8 @@ bool pn53x_set_tx_bits(const nfc_device_t* pnd, uint8_t ui8Bits); bool pn53x_wrap_frame(const byte_t* pbtTx, const size_t szTxBits, const byte_t* pbtTxPar, byte_t* pbtFrame, size_t* pszFrameBits); bool pn53x_unwrap_frame(const byte_t* pbtFrame, const size_t szFrameBits, byte_t* pbtRx, size_t* pszRxBits, byte_t* pbtRxPar); bool pn53x_decode_target_data(const byte_t* pbtRawData, size_t szDataLen, nfc_chip_t nc, nfc_target_type_t ntt, nfc_target_info_t* pnti); -bool pn53x_InListPassiveTarget(const nfc_device_t* pnd, const nfc_modulation_t nmInitModulation, const byte_t szMaxTargets, const byte_t* pbtInitiatorData, const size_t szInitiatorDataLen, size_t* pszTargets, byte_t* pbtTargetsData, size_t* pszTargetsData); + +bool pn53x_InListPassiveTarget(const nfc_device_t* pnd, const nfc_modulation_t nmInitModulation, const byte_t szMaxTargets, const byte_t* pbtInitiatorData, const size_t szInitiatorDataLen, byte_t* pbtTargetsData, size_t* pszTargetsData); + #endif // __NFC_CHIPS_PN53X_H__ diff --git a/libnfc/nfc.c b/libnfc/nfc.c index 5ba4950..d3dd28e 100644 --- a/libnfc/nfc.c +++ b/libnfc/nfc.c @@ -461,10 +461,10 @@ bool nfc_initiator_select_passive_target(const nfc_device_t* pnd, break; } - size_t szTargetFound, szTargetsData; + size_t szTargetsData; byte_t abtTargetsData[MAX_FRAME_LEN]; - if(!pn53x_InListPassiveTarget(pnd, nmInitModulation, 1, pbtInitData, szInitDataLen, &szTargetFound, abtTargetsData, &szTargetsData)) return false; + if(!pn53x_InListPassiveTarget(pnd, nmInitModulation, 1, pbtInitData, szInitDataLen, abtTargetsData, &szTargetsData)) return false; // Make sure one tag has been found, the PN53X returns 0x00 if none was available if (abtTargetsData[0] == 0) return false;