mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-19 13:00:42 -07:00
Topaz dump: remove unnecessary casts increasing required alignment and add dump size check
This commit is contained in:
parent
c9984985fd
commit
6a576701c7
1 changed files with 11 additions and 10 deletions
|
@ -583,9 +583,7 @@ static void topaz_print_lifecycle_state(uint8_t *data) {
|
||||||
// to be done
|
// to be done
|
||||||
}
|
}
|
||||||
|
|
||||||
static void printTopazDumpContents(uint8_t *dump, size_t size) {
|
static void printTopazDumpContents(topaz_tag_t *dump) {
|
||||||
|
|
||||||
topaz_tag_t *t = (topaz_tag_t *)dump;
|
|
||||||
|
|
||||||
// uses a global var for all
|
// uses a global var for all
|
||||||
PrintAndLogEx(NORMAL, "");
|
PrintAndLogEx(NORMAL, "");
|
||||||
|
@ -608,14 +606,14 @@ static void printTopazDumpContents(uint8_t *dump, size_t size) {
|
||||||
PrintAndLogEx(SUCCESS, " %3u / 0x%02x | %s| %s | %s",
|
PrintAndLogEx(SUCCESS, " %3u / 0x%02x | %s| %s | %s",
|
||||||
i,
|
i,
|
||||||
i,
|
i,
|
||||||
sprint_hex(&t->data_blocks[i][0], 8),
|
sprint_hex(&dump->data_blocks[i][0], 8),
|
||||||
lockstr,
|
lockstr,
|
||||||
block_info
|
block_info
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
PrintAndLogEx(SUCCESS, " %3u / 0x%02x | %s| | %s", 0x0D, 0x0D, sprint_hex(&t->data_blocks[0x0D][0], 8), topaz_ks[2]);
|
PrintAndLogEx(SUCCESS, " %3u / 0x%02x | %s| | %s", 0x0D, 0x0D, sprint_hex(&dump->data_blocks[0x0D][0], 8), topaz_ks[2]);
|
||||||
PrintAndLogEx(SUCCESS, " %3u / 0x%02x | %s| | %s", 0x0E, 0x0E, sprint_hex(&t->data_blocks[0x0E][0], 8), topaz_ks[3]);
|
PrintAndLogEx(SUCCESS, " %3u / 0x%02x | %s| | %s", 0x0E, 0x0E, sprint_hex(&dump->data_blocks[0x0E][0], 8), topaz_ks[3]);
|
||||||
PrintAndLogEx(SUCCESS, "------------+-------------------------+---+------------");
|
PrintAndLogEx(SUCCESS, "------------+-------------------------+---+------------");
|
||||||
PrintAndLogEx(NORMAL, "");
|
PrintAndLogEx(NORMAL, "");
|
||||||
}
|
}
|
||||||
|
@ -797,7 +795,7 @@ static int CmdHFTopazDump(const char *Cmd) {
|
||||||
if (status != PM3_SUCCESS) {
|
if (status != PM3_SUCCESS) {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
printTopazDumpContents((uint8_t *)&topaz_tag, sizeof(topaz_tag_t));
|
printTopazDumpContents(&topaz_tag);
|
||||||
|
|
||||||
bool set_dynamic = false;
|
bool set_dynamic = false;
|
||||||
if (topaz_set_cc_dynamic(&topaz_tag.data_blocks[1][0]) == PM3_SUCCESS) {
|
if (topaz_set_cc_dynamic(&topaz_tag.data_blocks[1][0]) == PM3_SUCCESS) {
|
||||||
|
@ -853,14 +851,17 @@ static int CmdHFTopazView(const char *Cmd) {
|
||||||
CLIParserFree(ctx);
|
CLIParserFree(ctx);
|
||||||
|
|
||||||
// read dump file
|
// read dump file
|
||||||
uint8_t *dump = NULL;
|
topaz_tag_t *dump = NULL;
|
||||||
size_t bytes_read = TOPAZ_MAX_SIZE;
|
size_t bytes_read = TOPAZ_MAX_SIZE;
|
||||||
int res = pm3_load_dump(filename, (void **)&dump, &bytes_read, sizeof(topaz_tag_t) + TOPAZ_MAX_SIZE);
|
int res = pm3_load_dump(filename, (void **)&dump, &bytes_read, sizeof(topaz_tag_t) + TOPAZ_MAX_SIZE);
|
||||||
if (res != PM3_SUCCESS) {
|
if (res != PM3_SUCCESS) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
if (bytes_read < sizeof(topaz_tag_t)) {
|
||||||
printTopazDumpContents(dump, bytes_read);
|
free(dump);
|
||||||
|
return PM3_EFAILED;
|
||||||
|
}
|
||||||
|
printTopazDumpContents(dump);
|
||||||
|
|
||||||
if (topaz_set_cc_dynamic(&topaz_tag.data_blocks[1][0]) == PM3_SUCCESS) {
|
if (topaz_set_cc_dynamic(&topaz_tag.data_blocks[1][0]) == PM3_SUCCESS) {
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue