rx buffer size parameter of pn53x_TgInitAsTarget() function is now a const size_t.

This commit is contained in:
Audrey Diacre 2012-01-09 10:47:35 +00:00
parent c10b473361
commit 5e796e0a26
2 changed files with 10 additions and 7 deletions

View file

@ -1745,10 +1745,10 @@ pn53x_target_init (struct nfc_device *pnd, nfc_target *pnt, uint8_t *pbtRx, size
while (!targetActivated) {
uint8_t btActivatedMode;
if((res = pn53x_TgInitAsTarget(pnd, ptm, pbtMifareParams, pbtTkt, szTkt, pbtFeliCaParams, pbtNFCID3t, pbtGBt, szGBt, pbtRx, pszRx, &btActivatedMode, timeout)) < 0) {
if((res = pn53x_TgInitAsTarget(pnd, ptm, pbtMifareParams, pbtTkt, szTkt, pbtFeliCaParams, pbtNFCID3t, pbtGBt, szGBt, pbtRx, *pszRx, &btActivatedMode, timeout)) < 0) {
return res;
}
*pszRx = (size_t) res;
nfc_modulation nm = {
.nmt = NMT_DEP, // Silent compilation warnings
.nbr = NBR_UNDEFINED
@ -2434,7 +2434,7 @@ pn53x_TgInitAsTarget (struct nfc_device *pnd, pn53x_target_mode ptm,
const uint8_t *pbtTkt, size_t szTkt,
const uint8_t *pbtFeliCaParams,
const uint8_t *pbtNFCID3t, const uint8_t *pbtGBt, const size_t szGBt,
uint8_t *pbtRx, size_t *pszRx, uint8_t *pbtModeByte, int timeout)
uint8_t *pbtRx, const size_t szRxLen, uint8_t *pbtModeByte, int timeout)
{
uint8_t abtCmd[39 + 47 + 48] = { TgInitAsTarget }; // Worst case: 39-byte base, 47 bytes max. for General Bytes, 48 bytes max. for Historical Bytes
size_t szOptionalBytes = 0;
@ -2494,11 +2494,14 @@ pn53x_TgInitAsTarget (struct nfc_device *pnd, pn53x_target_mode ptm,
}
// Save the received byte count
*pszRx = szRx - 1;
szRx -= 1;
if ((szRx - 1) > szRxLen)
return NFC_EOVFLOW;
// Copy the received bytes
memcpy (pbtRx, abtRx + 1, *pszRx);
memcpy (pbtRx, abtRx + 1, szRx);
return NFC_SUCCESS;
return szRx;
}
int

View file

@ -342,7 +342,7 @@ int pn53x_TgInitAsTarget (struct nfc_device *pnd, pn53x_target_mode ptm,
const uint8_t *pbtTkt, size_t szTkt,
const uint8_t *pbtFeliCaParams,
const uint8_t *pbtNFCID3t, const uint8_t *pbtGB, const size_t szGB,
uint8_t *pbtRx, size_t *pszRx, uint8_t *pbtModeByte, int timeout);
uint8_t *pbtRx, const size_t szRxLen, uint8_t *pbtModeByte, int timeout);
// RFConfiguration
int pn53x_RFConfiguration__RF_field (struct nfc_device *pnd, bool bEnable);