bad logic

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

View file

@ -425,15 +425,15 @@ 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 (tracelen > 0) {
if (!GetFromDevice(BIG_BUF, trace, tracelen, 0, NULL, 2500, false)) { if (!GetFromDevice(BIG_BUF, trace, tracelen, 0, NULL, 2500, false)) {
PrintAndLogEx(WARNING, "command execution time out"); PrintAndLogEx(WARNING, "command execution time out");
free(trace); free(trace);
@ -443,14 +443,13 @@ int CmdHFFelicaDumpLite(const char *Cmd) {
PrintAndLogEx(SUCCESS, "Recorded Activity (trace len = %d bytes)", tracelen); PrintAndLogEx(SUCCESS, "Recorded Activity (trace len = %d bytes)", tracelen);
print_hex_break(trace, tracelen, 32); print_hex_break(trace, tracelen, 32);
printSep(); printSep();
uint16_t tracepos = 0; uint16_t tracepos = 0;
while (tracepos < tracelen) while (tracepos < tracelen)
tracepos = PrintFliteBlock(tracepos, trace, tracelen); tracepos = PrintFliteBlock(tracepos, trace, tracelen);
printSep(); printSep();
}
free(trace); free(trace);
return 0; return 0;