From bd47a48d50fedf43bb68d656663cac299d5cdf1e Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Mon, 9 Nov 2026 14:55:58 +0700 Subject: [PATCH] trace save: return the download and file errors It returned PM3_SUCCESS when the trace download or writing the file failed, so scripts carried on as if the trace was saved. Co-Authored-By: Claude Opus 5.5 --- client/src/cmdtrace.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/client/src/cmdtrace.c b/client/src/cmdtrace.c index 006fca72c..a8023a24a 100644 --- a/client/src/cmdtrace.c +++ b/client/src/cmdtrace.c @@ -1637,12 +1637,15 @@ static int CmdTraceSave(const char *Cmd) { if ((use_buffer == false) && IfPm3Present()) { // saving is not supposed to alter the client side trace buffer, so // download to a buffer of our own and leave gs_trace alone - if (download_trace_ex(&trace, &trace_len) != PM3_SUCCESS) { - return PM3_SUCCESS; + int res = download_trace_ex(&trace, &trace_len); + if (res != PM3_SUCCESS) { + return res; } is_owner = true; } + int res = PM3_SUCCESS; + if (trace_len == 0) { PrintAndLogEx(WARNING, "trace is empty, nothing to save"); if (use_buffer) { @@ -1651,13 +1654,13 @@ static int CmdTraceSave(const char *Cmd) { PrintAndLogEx(HINT, "Hint: Try `" _YELLOW_("trace load") "` to load a trace from file"); } } else { - saveFile(filename, ".trace", trace, trace_len); + res = saveFile(filename, ".trace", trace, trace_len); } if (is_owner) { free(trace); } - return PM3_SUCCESS; + return res; } int CmdTraceListAlias(const char *Cmd, const char *alias, const char *protocol) {