trace list: don't truncate the arguments of the xx list aliases
CmdTraceListAlias() built "-t <protocol> <args>" in a 128 byte buffer, so a longer command line was cut silently, eg `hf mf list -f` with a long dictionary path tried to load a truncated file name and fell back to the default keys. Allocate the buffer to fit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
00a759b0c7
commit
b9863f3156
1 file changed
+11
-4
+11
-4
@@ -1692,10 +1692,17 @@ int CmdTraceListAlias(const char *Cmd, const char *alias, const char *protocol)
|
||||
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
||||
CLIParserFree(ctx);
|
||||
|
||||
char args[128] = {0};
|
||||
snprintf(args, sizeof(args), "-t %s ", protocol);
|
||||
strncat(args, Cmd, sizeof(args) - strlen(args) - 1);
|
||||
return CmdTraceList(args);
|
||||
// "-t " protocol " " Cmd NUL, sized to fit a long dictionary path
|
||||
size_t args_len = strlen(protocol) + strlen(Cmd) + 5;
|
||||
char *args = calloc(args_len, sizeof(char));
|
||||
if (args == NULL) {
|
||||
PrintAndLogEx(WARNING, "Failed to allocate memory");
|
||||
return PM3_EMALLOC;
|
||||
}
|
||||
snprintf(args, args_len, "-t %s %s", protocol, Cmd);
|
||||
int res = CmdTraceList(args);
|
||||
free(args);
|
||||
return res;
|
||||
}
|
||||
|
||||
int CmdTraceList(const char *Cmd) {
|
||||
|
||||
Reference in new issue
Block a user