bad logic

This commit is contained in:
iceman1001 2019-03-18 22:14:07 +01:00
commit b9cbc5cb7f

View file

@ -425,33 +425,32 @@ int CmdHFFelicaDumpLite(const char *Cmd) {
} }
uint64_t tracelen = resp.arg[1]; uint64_t tracelen = resp.arg[1];
if (tracelen == 0)
return 1;
uint8_t *trace = calloc(tracelen, sizeof(uint8_t)); uint8_t *trace = calloc(tracelen, sizeof(uint8_t));
if (trace == NULL) { if (trace == NULL) {
PrintAndLogEx(WARNING, "Cannot allocate memory for trace"); PrintAndLogEx(WARNING, "Cannot allocate memory for trace");
return 1; return 1;
} }
// only download data if there is any. if (!GetFromDevice(BIG_BUF, trace, tracelen, 0, NULL, 2500, false)) {
if (tracelen > 0) { PrintAndLogEx(WARNING, "command execution time out");
free(trace);
if (!GetFromDevice(BIG_BUF, trace, tracelen, 0, NULL, 2500, false)) { return 0;
PrintAndLogEx(WARNING, "command execution time out");
free(trace);
return 0;
}
PrintAndLogEx(SUCCESS, "Recorded Activity (trace len = %d bytes)", tracelen);
print_hex_break(trace, tracelen, 32);
printSep();
uint16_t tracepos = 0;
while (tracepos < tracelen)
tracepos = PrintFliteBlock(tracepos, trace, tracelen);
printSep();
} }
PrintAndLogEx(SUCCESS, "Recorded Activity (trace len = %d bytes)", tracelen);
print_hex_break(trace, tracelen, 32);
printSep();
uint16_t tracepos = 0;
while (tracepos < tracelen)
tracepos = PrintFliteBlock(tracepos, trace, tracelen);
printSep();
free(trace); free(trace);
return 0; return 0;
} }