From bbb438df71afb1b7d1993ae9e5272a7f5916fcc7 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Mon, 9 Nov 2026 14:37:33 +0700 Subject: [PATCH] trace list/extract: stop when the trace download fails Both ignored the result of download_trace(). After a timeout they went on with whatever the client side trace buffer held, ie an older trace, under a fresh "Recorded activity" line. Offline they printed the failed upload error and then listed the buffer anyway. Download only when a device is present and return its error, offline uses the trace buffer like `trace save` does. The "removing parameter -1" hint is only given when -1 was. Co-Authored-By: Claude Opus 5.5 --- client/src/cmdtrace.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/client/src/cmdtrace.c b/client/src/cmdtrace.c index af8175b10..e5a1c4595 100644 --- a/client/src/cmdtrace.c +++ b/client/src/cmdtrace.c @@ -1490,11 +1490,19 @@ static int CmdTraceExtract(const char *Cmd) { clearCommandBuffer(); - if (use_buffer == false) { - download_trace(); + // offline falls back to the trace buffer, like `trace save` + if ((use_buffer == false) && IfPm3Present()) { + int res = download_trace(); + if (res != PM3_SUCCESS) { + return res; + } } else if (gs_traceLen == 0) { PrintAndLogEx(FAILED, "You requested a trace list in offline mode but there is no trace."); - PrintAndLogEx(FAILED, "Consider using `" _YELLOW_("trace load") "` or removing parameter `" _YELLOW_("-1") "`"); + if (use_buffer) { + PrintAndLogEx(FAILED, "Consider using `" _YELLOW_("trace load") "` or removing parameter `" _YELLOW_("-1") "`"); + } else { + PrintAndLogEx(FAILED, "Consider using `" _YELLOW_("trace load") "`"); + } return PM3_EINVARG; } @@ -1788,8 +1796,12 @@ int CmdTraceList(const char *Cmd) { return PM3_EINVARG; } - if (use_buffer == false) { - download_trace(); + // offline falls back to the trace buffer, like `trace save` + if ((use_buffer == false) && IfPm3Present()) { + int res = download_trace(); + if (res != PM3_SUCCESS) { + return res; + } } else if (gs_traceLen == 0 || gs_trace == NULL) { if (IfPm3Present() == false) { @@ -1798,7 +1810,11 @@ int CmdTraceList(const char *Cmd) { PrintAndLogEx(FAILED, "You requested a trace list but there is no trace."); } - PrintAndLogEx(FAILED, "Consider using `" _YELLOW_("trace load") "` or removing parameter `" _YELLOW_("-1") "`"); + if (use_buffer) { + PrintAndLogEx(FAILED, "Consider using `" _YELLOW_("trace load") "` or removing parameter `" _YELLOW_("-1") "`"); + } else { + PrintAndLogEx(FAILED, "Consider using `" _YELLOW_("trace load") "`"); + } return PM3_EINVARG; }