fix coverity #910669
This commit is contained in:
1 parent
c118e1cf20
commit
2d43d4c021
2 files changed
+30
-9
No files matched your search
@@ -167,8 +167,13 @@ static int saMifareChkKeys(uint8_t const blockNo, uint8_t const keyType, bool co
|
||||
mfKey &= MATTYRUN_MFC_KEY_BITS;
|
||||
|
||||
if (mattyrun_card.uidlen == 0) {
|
||||
if (!saMifareDiscover()) {
|
||||
--i; // try same key once again
|
||||
|
||||
if (saMifareDiscover() == false) {
|
||||
|
||||
if (i) {
|
||||
--i; // try same key once again
|
||||
}
|
||||
|
||||
--selectRetries;
|
||||
if (selectRetries > 0) {
|
||||
continue;
|
||||
@@ -177,26 +182,35 @@ static int saMifareChkKeys(uint8_t const blockNo, uint8_t const keyType, bool co
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if (cascade_levels == 0) {
|
||||
switch (mattyrun_card.uidlen) {
|
||||
case 4:
|
||||
case 4: {
|
||||
cascade_levels = 1;
|
||||
break;
|
||||
case 7:
|
||||
}
|
||||
case 7: {
|
||||
cascade_levels = 2;
|
||||
break;
|
||||
case 10:
|
||||
}
|
||||
case 10: {
|
||||
cascade_levels = 3;
|
||||
break;
|
||||
default:
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// No need for anticollision. Since we sucessfully selected the card before,
|
||||
// we can directly select the card again
|
||||
if (iso14443a_fast_select_card(mattyrun_uid, cascade_levels) == 0) {
|
||||
--i; // try same key once again
|
||||
if (i) {
|
||||
--i; // try same key once again
|
||||
}
|
||||
|
||||
--selectRetries;
|
||||
if (selectRetries > 0) {
|
||||
continue;
|
||||
@@ -211,10 +225,12 @@ static int saMifareChkKeys(uint8_t const blockNo, uint8_t const keyType, bool co
|
||||
|
||||
authres = mifare_classic_auth(pcs, mattyrun_cuid, blockNo, keyType, mfKey, AUTH_FIRST);
|
||||
if (authres) {
|
||||
|
||||
uint8_t dummy_answer = 0;
|
||||
ReaderTransmit(&dummy_answer, 1, NULL);
|
||||
// wait for the card to become ready again
|
||||
SpinDelayUs(AUTHENTICATION_TIMEOUT);
|
||||
|
||||
if (authres == 1) {
|
||||
retval = -3;
|
||||
break;
|
||||
@@ -222,6 +238,7 @@ static int saMifareChkKeys(uint8_t const blockNo, uint8_t const keyType, bool co
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
*key = mfKey;
|
||||
retval = i;
|
||||
break;
|
||||
|
||||
+6
-2
@@ -2562,7 +2562,9 @@ void MifareChkKeys(uint8_t *datain, uint8_t reserved_mem) {
|
||||
iso14a_card_select_t card_info;
|
||||
if (iso14443a_select_card(uid, &card_info, &cuid, true, 0, true) == false) {
|
||||
if (g_dbglevel >= DBG_ERROR) Dbprintf("ChkKeys: Can't select card (ALL)");
|
||||
--i; // try same key once again
|
||||
if (i) {
|
||||
--i; // try same key once again
|
||||
}
|
||||
continue;
|
||||
}
|
||||
switch (card_info.uidlen) {
|
||||
@@ -2582,7 +2584,9 @@ void MifareChkKeys(uint8_t *datain, uint8_t reserved_mem) {
|
||||
} else { // no need for anticollision. We can directly select the card
|
||||
if (iso14443a_select_card(uid, NULL, NULL, false, cascade_levels, true) == false) {
|
||||
if (g_dbglevel >= DBG_ERROR) Dbprintf("ChkKeys: Can't select card (UID)");
|
||||
--i; // try same key once again
|
||||
if (i) {
|
||||
--i; // try same key once again
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user