mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-01-13 11:40:02 +08:00
fix memmove if len=0
This commit is contained in:
parent
0e5d896893
commit
69f3e65dd0
1 changed files with 13 additions and 11 deletions
|
@ -2266,32 +2266,34 @@ int iso14_apdu(uint8_t *cmd, uint16_t cmd_len, bool send_chaining, void *data, u
|
||||||
iso14a_set_timeout(save_iso14a_timeout);
|
iso14a_set_timeout(save_iso14a_timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we received an I- or R(ACK)-Block with a block number equal to the
|
// if we received an I- or R(ACK)-Block with a block number equal to the
|
||||||
// current block number, toggle the current block number
|
// current block number, toggle the current block number
|
||||||
if (len >= 3 // PCB+CRC = 3 bytes
|
if (len >= 3 // PCB+CRC = 3 bytes
|
||||||
&& ((data_bytes[0] & 0xC0) == 0 // I-Block
|
&& ((data_bytes[0] & 0xC0) == 0 // I-Block
|
||||||
|| (data_bytes[0] & 0xD0) == 0x80) // R-Block with ACK bit set to 0
|
|| (data_bytes[0] & 0xD0) == 0x80) // R-Block with ACK bit set to 0
|
||||||
&& (data_bytes[0] & 0x01) == iso14_pcb_blocknum) // equal block numbers
|
&& (data_bytes[0] & 0x01) == iso14_pcb_blocknum) // equal block numbers
|
||||||
{
|
{
|
||||||
iso14_pcb_blocknum ^= 1;
|
iso14_pcb_blocknum ^= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we received I-block with chaining we need to send ACK and receive another block of data
|
// if we received I-block with chaining we need to send ACK and receive another block of data
|
||||||
if (res)
|
if (res)
|
||||||
*res = data_bytes[0];
|
*res = data_bytes[0];
|
||||||
|
|
||||||
// crc check
|
// crc check
|
||||||
if (len >=3 && !check_crc(CRC_14443_A, data_bytes, len)) {
|
if (len >= 3 && !check_crc(CRC_14443_A, data_bytes, len)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// cut frame byte
|
if (len) {
|
||||||
len -= 1;
|
// cut frame byte
|
||||||
// memmove(data_bytes, data_bytes + 1, len);
|
len -= 1;
|
||||||
for (int i = 0; i < len; i++)
|
// memmove(data_bytes, data_bytes + 1, len);
|
||||||
data_bytes[i] = data_bytes[i + 1];
|
for (int i = 0; i < len; i++)
|
||||||
|
data_bytes[i] = data_bytes[i + 1];
|
||||||
|
}
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue