Pārlūkot izejas kodu

hiding input in command not found message with disabled echo
this shall prevent writing potentially secret information more often than required on the bus

Strobel, Stefan | Friedrich Lütze GmbH 9 mēneši atpakaļ
vecāks
revīzija
8a14afc035
2 mainītis faili ar 12 papildinājumiem un 5 dzēšanām
  1. 10 3
      src/shellmatta.c
  2. 2 2
      test/integrationtest/test_integration.cpp

+ 10 - 3
src/shellmatta.c

@@ -670,9 +670,16 @@ shellmatta_retCode_t shellmatta_processData(shellmatta_handle_t     handle,
 
                     if ((0u == cmdExecuted) && (inst->inputCount > 0))
                     {
-                        inst->write("\r\nCommand: ", 11u);
-                        inst->write(inst->buffer, inst->inputCount);
-                        inst->write(" not found", 10u);
+                        if (inst->echoEnabled)
+                        {
+                            inst->write("\r\nCommand: ", 11u);
+                            inst->write(inst->buffer, inst->inputCount);
+                            inst->write(" not found", 10u);
+                        }
+                        else
+                        {
+                            inst->write("\r\nCommand not found!", 20u);
+                        }
                     }
 
                     /** -# terminate this session if no continuous mode is requested */

+ 2 - 2
test/integrationtest/test_integration.cpp

@@ -418,9 +418,9 @@ TEST_CASE( "shellmatta configure mode" ) {
     shellmatta_retCode_t ret;
     char buffer[1024];
     char historyBuffer[1024];
-    char *dummyData =   (char*)"\r\nCommand: meow this is some dum123456my Text not found\r\nshellmatta->";
+    char *dummyData =   (char*)"\r\nCommand not found!\r\nshellmatta->";
 
-    char *dummyData2 =   (char*)"\r\nCommand: meow this is some dum123456t not found\r\nshellmatta->";
+    char *dummyData2 =   (char*)"\r\nCommand not found!\r\nshellmatta->";
 
     shellmatta_doInit(  &inst,
                         &handle,