diff --git a/client/src/cmdhf14a.c b/client/src/cmdhf14a.c index 8c09b990c..74fe60281 100644 --- a/client/src/cmdhf14a.c +++ b/client/src/cmdhf14a.c @@ -171,14 +171,7 @@ static uint16_t frameLength = 0; uint16_t atsFSC[] = {16, 24, 32, 40, 48, 64, 96, 128, 256}; static int CmdHF14AList(const char *Cmd) { - int ret = CmdTraceListAlias(Cmd, "hf 14a list"); - if (ret != PM3_SUCCESS) { - return ret; - } - char args[128] = {0}; - snprintf(args, sizeof(args), "-t 14a "); - strncat(args, Cmd, sizeof(args) - strlen(args)); - return CmdTraceList(args); + return CmdTraceListAlias(Cmd, "hf 14a", "14a"); } int hf14a_getconfig(hf14a_config *config) { diff --git a/client/src/cmdtrace.c b/client/src/cmdtrace.c index 50f67ff05..e3b371c57 100644 --- a/client/src/cmdtrace.c +++ b/client/src/cmdtrace.c @@ -591,19 +591,22 @@ static int CmdTraceSave(const char *Cmd) { return PM3_SUCCESS; } -int CmdTraceListAlias(const char *Cmd, const char *alias) { +int CmdTraceListAlias(const char *Cmd, const char *alias, const char *protocol) { CLIParserContext *ctx; + char desc[500] = {0}; + snprintf(desc, sizeof(desc) - 1, + "Alias of `trace list -t %s` with selected protocol data to annotate trace buffer\n" + "You can load a trace from file (see `trace load -h`) or it be downloaded from device by default\n" + "It accepts all other arguments of `trace list`. Note that some might not be relevant for this specific protocol", + protocol); char example[200] = {0}; - sprintf(example, - "%s -f -> show frame delay times\n" - "%s -1 -> use trace buffer ", + snprintf(example, sizeof(example) - 1, + "%s list -f -> show frame delay times\n" + "%s list -1 -> use trace buffer ", alias, alias); - CLIParserInit(&ctx, alias, - "Alias of `trace list -t` with selected protocol data to annotate trace buffer\n" - "You can load a trace from file (see `trace load -h`) or it be downloaded from device by default\n" - "It accepts all other arguments of `trace list`. Note that some might not be relevant for this specific protocol", - example - ); + char fullalias[100] = {0}; + snprintf(fullalias, sizeof(fullalias) - 1, "%s list", alias); + CLIParserInit(&ctx, fullalias, desc, example); void *argtable[] = { arg_param_begin, @@ -618,8 +621,10 @@ int CmdTraceListAlias(const char *Cmd, const char *alias) { arg_param_end }; CLIExecWithReturn(ctx, Cmd, argtable, true); - CLIParserFree(ctx); - return PM3_SUCCESS; + char args[128] = {0}; + snprintf(args, sizeof(args), "-t %s ", protocol); + strncat(args, Cmd, sizeof(args) - strlen(args)); + return CmdTraceList(args); } int CmdTraceList(const char *Cmd) { diff --git a/client/src/cmdtrace.h b/client/src/cmdtrace.h index d4a9cd108..7444fe62e 100644 --- a/client/src/cmdtrace.h +++ b/client/src/cmdtrace.h @@ -15,6 +15,6 @@ int CmdTrace(const char *Cmd); int CmdTraceList(const char *Cmd); -int CmdTraceListAlias(const char *Cmd, const char *alias); +int CmdTraceListAlias(const char *Cmd, const char *alias, const char *protocol); #endif