From 4b936bc20cd11c7139f27acf56fe2466242bf102 Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Mon, 13 Dec 2021 03:16:57 +0100 Subject: [PATCH] safer logic when touching locally g_printAndLog --- client/src/cmdparser.c | 2 +- client/src/proxguiqt.cpp | 9 +++++---- client/src/proxmark3.c | 11 ++++++----- doc/commands.json | 2 +- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/client/src/cmdparser.c b/client/src/cmdparser.c index 100de37f3..2bc95d8fb 100644 --- a/client/src/cmdparser.c +++ b/client/src/cmdparser.c @@ -182,7 +182,7 @@ void CmdsHelp(const command_t Commands[]) { while (Commands[i].Name) { if (Commands[i].IsAvailable()) { uint8_t old_printAndLog = g_printAndLog; - g_printAndLog = PRINTANDLOG_PRINT; + g_printAndLog &= PRINTANDLOG_PRINT; if (Commands[i].Name[0] == '-' || Commands[i].Name[0] == ' ') { PrintAndLogEx(NORMAL, "%-16s %s", Commands[i].Name, Commands[i].Help); } else { diff --git a/client/src/proxguiqt.cpp b/client/src/proxguiqt.cpp index 467d46374..d8181bb3d 100644 --- a/client/src/proxguiqt.cpp +++ b/client/src/proxguiqt.cpp @@ -1005,8 +1005,9 @@ void Plot::keyPressEvent(QKeyEvent *event) { } break; - case Qt::Key_H: - g_printAndLog = PRINTANDLOG_PRINT; + case Qt::Key_H: { + uint8_t old_printAndLog = g_printAndLog; + g_printAndLog &= PRINTANDLOG_PRINT; PrintAndLogEx(NORMAL, "\n\n" _CYAN_("PLOT window keystrokes and mouse events")); PrintAndLogEx(NORMAL, "\n" _GREEN_("Move:")); PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9 + 9, _RED_("Home") "/" _RED_("End"), "Move to the start/end of the graph"); @@ -1031,9 +1032,9 @@ void Plot::keyPressEvent(QKeyEvent *event) { PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9, _YELLOW_("Right mouse click"), "Set purple cursor"); PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9, _RED_("h"), "Show this help"); PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9, _RED_("q"), "Close plot window"); - g_printAndLog = PRINTANDLOG_PRINT | PRINTANDLOG_LOG; + g_printAndLog = old_printAndLog; break; - + } case Qt::Key_L: g_GridLocked = !g_GridLocked; if (g_GridLocked) diff --git a/client/src/proxmark3.c b/client/src/proxmark3.c index 91117416f..99403eab2 100644 --- a/client/src/proxmark3.c +++ b/client/src/proxmark3.c @@ -93,8 +93,8 @@ static void showBanner_logo(LogoMode mode) { } static void showBanner(void) { - - g_printAndLog = PRINTANDLOG_PRINT; + uint8_t old_printAndLog = g_printAndLog; + g_printAndLog &= PRINTANDLOG_PRINT; PrintAndLogEx(NORMAL, "\n"); #if defined(_WIN32) @@ -114,7 +114,7 @@ static void showBanner(void) { // PrintAndLogEx(NORMAL, "\nMonero: 43mNJLpgBVaTvyZmX9ajcohpvVkaRy1kbZPm8tqAb7itZgfuYecgkRF36rXrKFUkwEGeZedPsASRxgv4HPBHvJwyJdyvQuP"); PrintAndLogEx(NORMAL, ""); fflush(stdout); - g_printAndLog = PRINTANDLOG_PRINT | PRINTANDLOG_LOG; + g_printAndLog = old_printAndLog; } #endif //LIBPM3 @@ -436,8 +436,9 @@ check_script: cmd[strlen(cmd) - off] = '\0'; if (cmd[0] != '\0') { + uint8_t old_printAndLog = g_printAndLog; if (!printprompt) { - g_printAndLog = PRINTANDLOG_LOG; + g_printAndLog &= PRINTANDLOG_LOG; } char prompt[PROXPROMPT_MAX_SIZE] = {0}; prompt_compose(prompt, sizeof(prompt), prompt_ctx, prompt_dev); @@ -445,7 +446,7 @@ check_script: char prompt_filtered[PROXPROMPT_MAX_SIZE] = {0}; memcpy_filter_rlmarkers(prompt_filtered, prompt, sizeof(prompt_filtered)); PrintAndLogEx(NORMAL, "%s%s", prompt_filtered, cmd); - g_printAndLog = PRINTANDLOG_PRINT | PRINTANDLOG_LOG; + g_printAndLog = old_printAndLog; #ifdef HAVE_READLINE // add to history if not from a script diff --git a/doc/commands.json b/doc/commands.json index 15431e29b..dfef59fe7 100644 --- a/doc/commands.json +++ b/doc/commands.json @@ -10041,6 +10041,6 @@ "metadata": { "commands_extracted": 589, "extracted_by": "PM3Help2JSON v1.00", - "extracted_on": "2021-12-13T01:57:16" + "extracted_on": "2021-12-13T02:15:15" } } \ No newline at end of file