not allow to write block 0

This commit is contained in:
Willok
2020-06-22 11:07:52 +08:00
parent a83b6feb38
commit 4ac715463c
@@ -1020,12 +1020,20 @@ uint16_t MifareClassicAppProcess(uint8_t *Buffer, uint16_t BitCount) {
}
} else if (Buffer[0] == CMD_WRITE) {
if (ISO14443ACheckCRCA(Buffer, CMD_WRITE_FRAME_SIZE)) {
DetectionLogToFlash(LOG_INFO_APP_CMD_WRITE, Buffer, 2);
/* Write command. Store the address and prepare for the upcoming data.
* Respond with ACK. */
CurrentAddress = Buffer[1];
State = STATE_WRITE;
Buffer[0] = ACK_VALUE ^ Crypto1Nibble();
// not allow to write block 0
if (Buffer[1] == 0x00) {
State = STATE_HALT;
Buffer[0] = NAK_NOT_AUTHED ^ Crypto1Nibble();
return ACK_NAK_FRAME_SIZE;
}
else {
DetectionLogToFlash(LOG_INFO_APP_CMD_WRITE, Buffer, 2);
/* Write command. Store the address and prepare for the upcoming data.
* Respond with ACK. */
CurrentAddress = Buffer[1];
State = STATE_WRITE;
Buffer[0] = ACK_VALUE ^ Crypto1Nibble();
}
} else {
LogEntry(LOG_ERR_APP_CHECKSUM_FAIL, Buffer, 4);
Buffer[0] = NAK_CRC_ERROR ^ Crypto1Nibble();