Fix MAD1 off-by-one in MADDecode: loop read Key A as 16th AID

This commit is contained in:
achazal
2026-06-02 19:02:05 +02:00
parent c46b72ee2b
commit 6aa8a2f892
2 changed files with 3 additions and 4 deletions
+1 -2
View File
@@ -262,8 +262,7 @@ int MADDecode(uint8_t *sector0, uint8_t *sector16, uint16_t *mad, size_t *madlen
PrintAndLogEx(INFO, "overriding crc check");
}
// 7 + 8 == 15
for (int i = 1; i <= 16; i++) {
for (int i = 1; i < 16; i++) {
mad[*madlen] = madGetAID(sector0, swapmad, 1, i);
(*madlen)++;
}
+2 -2
View File
@@ -21,8 +21,8 @@
#include "common.h"
// 16 MAD1 AIDs + 1 MAD2 marker (0x0005) + 23 MAD2 AIDs = 40
#define MAD_MAX_AID_ENTRIES 40
// 15 MAD1 AIDs (sectors 1-15) + 1 MAD2 marker (0x0005) + 23 MAD2 AIDs (sectors 17-39) = 39
#define MAD_MAX_AID_ENTRIES 39
int MADCheck(uint8_t *sector0, uint8_t *sector16, bool verbose, bool *haveMAD2);
int MADDecode(uint8_t *sector0, uint8_t *sector16, uint16_t *mad, size_t *madlen, bool swapmad, bool override);