fix memmove if len=0
This commit is contained in:
@@ -2281,17 +2281,19 @@ int iso14_apdu(uint8_t *cmd, uint16_t cmd_len, bool send_chaining, void *data, u
|
|||||||
*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;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (len) {
|
||||||
// cut frame byte
|
// cut frame byte
|
||||||
len -= 1;
|
len -= 1;
|
||||||
// memmove(data_bytes, data_bytes + 1, len);
|
// memmove(data_bytes, data_bytes + 1, len);
|
||||||
for (int i = 0; i < len; i++)
|
for (int i = 0; i < len; i++)
|
||||||
data_bytes[i] = data_bytes[i + 1];
|
data_bytes[i] = data_bytes[i + 1];
|
||||||
|
}
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user