From 4935cf5fb396d0e0c5bd3b025fbc5bb19650592a Mon Sep 17 00:00:00 2001 From: Matthew Kennedy Date: Fri, 31 Mar 2023 23:11:01 -0700 Subject: [PATCH] more dead stuff (cherry picked from commit b9d065ae4e867e65d2ab9049961a4044d967013d) --- firmware/util/cli_registry.cpp | 38 ---------------------------------- firmware/util/cli_registry.h | 1 - unit_tests/tests/test_util.cpp | 2 -- 3 files changed, 41 deletions(-) diff --git a/firmware/util/cli_registry.cpp b/firmware/util/cli_registry.cpp index e880b0912c..a4193713cc 100644 --- a/firmware/util/cli_registry.cpp +++ b/firmware/util/cli_registry.cpp @@ -32,9 +32,6 @@ static int consoleActionCount = 0; static TokenCallback consoleActions[CONSOLE_MAX_ACTIONS] CCM_OPTIONAL; -#define SECURE_LINE_PREFIX "sec!" -#define SECURE_LINE_PREFIX_LENGTH 4 - void resetConsoleActions(void) { consoleActionCount = 0; } @@ -468,40 +465,6 @@ void initConsoleLogic() { addConsoleActionI("echo", echo); } -/** - * @return NULL if input line validation failed, reference to line payload if validation succeeded. - * @see sendOutConfirmation() for command confirmation processing. - */ -char *validateSecureLine(char *line) { - if (line == NULL) - return NULL; - if (strncmp(SECURE_LINE_PREFIX, line, SECURE_LINE_PREFIX_LENGTH) == 0) { - // COM protocol looses bytes, this is a super-naive error detection - -// print("Got secure mode request header [%s]\r\n", line); - line += SECURE_LINE_PREFIX_LENGTH; -// print("Got secure mode request command [%s]\r\n", line); - - char *divider = line; - while (*divider != '!') { - if (*divider == '\0') { - efiPrintf("Divider not found [%s]", line); - return NULL; - } - divider++; - } - *divider++ = 0; // replacing divider symbol with zero - int expectedLength = atoi(line); - line = divider; - int actualLength = strlen(line); - if (expectedLength != actualLength) { - efiPrintf("Error detected: expected %d but got %d in [%s]", expectedLength, actualLength, line); - return NULL; - } - } - return line; -} - static char handleBuffer[MAX_CMD_LINE_LENGTH + 1]; static int handleConsoleLineInternal(const char *commandLine, int lineLength) { @@ -540,7 +503,6 @@ static int handleConsoleLineInternal(const char *commandLine, int lineLength) { * @brief This function takes care of one command line once we have it */ void handleConsoleLine(char *line) { - line = validateSecureLine(line); if (line == NULL) return; // error detected diff --git a/firmware/util/cli_registry.h b/firmware/util/cli_registry.h index 8a5b8580b9..98b4579fa2 100644 --- a/firmware/util/cli_registry.h +++ b/firmware/util/cli_registry.h @@ -51,7 +51,6 @@ extern "C" { #endif /* __cplusplus */ -char *validateSecureLine(char *line); void resetConsoleActions(void); void helpCommand(void); void initConsoleLogic(); diff --git a/unit_tests/tests/test_util.cpp b/unit_tests/tests/test_util.cpp index f98a26a23f..4f774b2217 100644 --- a/unit_tests/tests/test_util.cpp +++ b/unit_tests/tests/test_util.cpp @@ -324,8 +324,6 @@ TEST(misc, testConsoleLogic) { strcpy(buffer, "\"echo\""); ASSERT_TRUE(strEqual("echo", unquote(buffer))) << "unquote quoted"; - char *ptr = validateSecureLine(UNKNOWN_COMMAND); - ASSERT_EQ(0, strcmp(UNKNOWN_COMMAND, ptr)); ASSERT_EQ(10, tokenLength(UNKNOWN_COMMAND)); // handling invalid token should work