refactoring fix

This commit is contained in:
merlokk 2021-07-24 00:52:54 +03:00
commit 4444fb4533
2 changed files with 13 additions and 15 deletions

View file

@ -6216,7 +6216,7 @@ static int CmdHF14ADesCreateFile(const char *Cmd) {
if (useraw && sdatalen > 0) {
filetype = rawftype;
memcpy(&data[1], sdata, sdatalen);
datalen += sdatalen;
datalen = 1 + sdatalen;
} else {
useraw = false;
}
@ -6394,21 +6394,17 @@ static int CmdHF14ADesCreateValueFile(const char *Cmd) {
if (verbose)
PrintAndLogEx(INFO, "App: %06x. File num: 0x%02x type: 0x%02x data[%d]: %s", appid, data[0], filetype, datalen, sprint_hex(data, datalen));
DesfirePrintCreateFileSettings(filetype, data, datalen);
res = DesfireCreateFile(&dctx, filetype, data, datalen, true);
if (res != PM3_SUCCESS) {
PrintAndLogEx(ERR, "Desfire CreateFile command " _RED_("error") ". Result: %d", res);
DropField();
return PM3_ESOFT;
}
PrintAndLogEx(SUCCESS, "Value file %02x in the app %06x created " _GREEN_("successfully"), data[0], appid);
DropField();
return PM3_SUCCESS;

View file

@ -1371,7 +1371,7 @@ void DesfirePrintCreateFileSettings(uint8_t filetype, uint8_t *data, size_t len)
return;
}
bool isoidpresent = ftyperec->mayHaveISOfid; // TODO!!!
bool isoidpresent = ftyperec->mayHaveISOfid && (len == ftyperec->len + 2 + 1);
PrintAndLogEx(INFO, "---- " _CYAN_("Create file settings") " ----");
PrintAndLogEx(SUCCESS, "File type : %s", ftyperec->text);
@ -1380,8 +1380,10 @@ void DesfirePrintCreateFileSettings(uint8_t filetype, uint8_t *data, size_t len)
if (isoidpresent) {
PrintAndLogEx(SUCCESS, "File ISO number : 0x%02x%02x", data[xlen], data[xlen + 1]);
xlen += 2;
} else {
PrintAndLogEx(SUCCESS, "File ISO number : n/a");
}
PrintAndLogEx(SUCCESS, "File comm mode : %s", GetDesfireCommunicationMode(data[xlen] & 0x03));
bool addaccess = ((data[xlen] & 0x80) != 0);
PrintAndLogEx(SUCCESS, "Additional access: %s", (addaccess) ? "Yes" : "No");