diff --git a/client/src/cmdhfmf.c b/client/src/cmdhfmf.c index 6f28d7d7c..bbeaa5fce 100644 --- a/client/src/cmdhfmf.c +++ b/client/src/cmdhfmf.c @@ -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);