diff --git a/armsrc/mifarecmd.c b/armsrc/mifarecmd.c index 3d552cee..b9032c5f 100644 --- a/armsrc/mifarecmd.c +++ b/armsrc/mifarecmd.c @@ -1019,29 +1019,26 @@ void MifareChkKeys(uint16_t arg0, uint32_t arg1, uint8_t arg2, uint8_t *datain) int OLD_MF_DBGLEVEL = MF_DBGLEVEL; MF_DBGLEVEL = MF_DBG_NONE; + int res = 0; if (multisectorCheck) { TKeyIndex keyIndex = {{0}}; uint8_t sectorCnt = blockNo; - int res = MifareMultisectorChk(datain, keyCount, sectorCnt, keyType, &auth_timeout, OLD_MF_DBGLEVEL, &keyIndex); - + res = MifareMultisectorChk(datain, keyCount, sectorCnt, keyType, &auth_timeout, OLD_MF_DBGLEVEL, &keyIndex); if (res >= 0) { cmd_send(CMD_ACK, 1, res, 0, keyIndex, 80); } else { cmd_send(CMD_ACK, 0, res, 0, NULL, 0); - drop_field = true; } } else { - int res = MifareChkBlockKeys(datain, keyCount, blockNo, keyType, &auth_timeout, OLD_MF_DBGLEVEL); - + res = MifareChkBlockKeys(datain, keyCount, blockNo, keyType, &auth_timeout, OLD_MF_DBGLEVEL); if (res > 0) { cmd_send(CMD_ACK, 1, res, 0, datain + (res - 1) * 6, 6); } else { cmd_send(CMD_ACK, 0, res, 0, NULL, 0); - drop_field = true; } } - if (drop_field) { + if (drop_field || res != 0) { FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); LED_D_OFF(); } diff --git a/armsrc/mifareutil.c b/armsrc/mifareutil.c index 8b5a7643..1d50f002 100644 --- a/armsrc/mifareutil.c +++ b/armsrc/mifareutil.c @@ -910,10 +910,10 @@ int MifareMultisectorChk(uint8_t *keys, uint8_t keyCount, uint8_t SectorCount, u int keyAB = keyType; do { res = MifareChkBlockKeys(keys, keyCount, FirstBlockOfSector(sc), keyAB & 0x01, auth_timeout, debugLevel); - if (res < 0){ + if (res < 0) { return res; } - if (res > 0){ + if (res > 0) { (*keyIndex)[keyAB & 0x01][sc] = res; } } while(--keyAB > 0);