From 23fbdd2f5278d6ac89e5a4b196302f6acd3f303c Mon Sep 17 00:00:00 2001 From: suut Date: Mon, 4 May 2026 23:23:54 +0200 Subject: [PATCH] Fix typo, check if raw blocks are given in ascending order --- client/src/cmdhfmfdes.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/client/src/cmdhfmfdes.c b/client/src/cmdhfmfdes.c index ea3d3e186..f128c5492 100644 --- a/client/src/cmdhfmfdes.c +++ b/client/src/cmdhfmfdes.c @@ -6439,6 +6439,7 @@ static int CmdHF14ADesMakeMFCLicense(const char *Cmd) { uint8_t last_sector = license[1] / 4; num_sectors = 1; + int last_block = -1; for (int i = 0; i < num_blocks; i++) { uint8_t block_nr = license[1 + 2*i]; @@ -6449,6 +6450,12 @@ static int CmdHF14ADesMakeMFCLicense(const char *Cmd) { last_sector = block_nr / 4; } + if (block_nr <= last_block) { + PrintAndLogEx(ERR, "Blocks must be unique and sorted in ascending order"); + goto mfclicense_parsing_error; + } + last_block = block_nr; + if (block_nr >= 64) { PrintAndLogEx(ERR, "Invalid block number %d", block_nr); goto mfclicense_parsing_error; @@ -6596,10 +6603,10 @@ static int CmdHF14ADesMakeMFCLicense(const char *Cmd) { PrintAndLogEx(INFO, "MAC: %s", sprint_hex_inrow(mac, 8)); if (save) { - memset(saved_mfclicense, license, license_len); + memcpy(saved_mfclicense, license, license_len); saved_mfclicense_len = license_len; saved_mfclicense_set = true; - memset(saved_mfclicense_mac, mac, 8); + memcpy(saved_mfclicense_mac, mac, 8); saved_mfclicense_mac_set = true; PrintAndLogEx(INFO, "Saved license and license MAC for the next commands in this session"); }