coverity believes somehow the return value from mfSectorNum can be 31. And wants us to check that it is only same size as sectors allocated

This commit is contained in:
iceman1001 2023-07-24 15:11:21 +02:00
parent 72057f9b81
commit fcde2978a8

View file

@ -376,13 +376,14 @@ static int mf_print_keys(uint16_t n, uint8_t *d) {
}
for (uint16_t i = 0; i < n; i++) {
if (mfIsSectorTrailer(i)) {
uint8_t sec = mfSectorNum(i);
e_sector[sec].foundKey[0] = 1;
e_sector[sec].Key[0] = bytes_to_num(d + (i * MFBLOCK_SIZE), MIFARE_KEY_SIZE);
e_sector[sec].foundKey[1] = 1;
e_sector[sec].Key[1] = bytes_to_num(d + (i * MFBLOCK_SIZE) + 10, MIFARE_KEY_SIZE);
if (mfIsSectorTrailer(i) == false) {
continue;
}
uint8_t sec = MIN(sectors, mfSectorNum(i));
e_sector[sec].foundKey[0] = 1;
e_sector[sec].Key[0] = bytes_to_num(d + (i * MFBLOCK_SIZE), MIFARE_KEY_SIZE);
e_sector[sec].foundKey[1] = 1;
e_sector[sec].Key[1] = bytes_to_num(d + (i * MFBLOCK_SIZE) + 10, MIFARE_KEY_SIZE);
}
printKeyTable(sectors, e_sector);
free(e_sector);