Browse Source

parse command only until strlen(cmd) fix #16

prozessorkern 5 years ago
parent
commit
5b6f2155eb
1 changed files with 7 additions and 2 deletions
  1. 7 2
      src/shellmatta.c

+ 7 - 2
src/shellmatta.c

@@ -228,8 +228,13 @@ shellmatta_retCode_t shellmatta_processData(shellmatta_handle_t     handle,
                 /** -# search for a matching command */
                 while (NULL != cmd)
                 {
-                    if (    (0 == strcmp(inst->buffer, cmd->cmd))
-                        ||  (0 == strcmp(inst->buffer, cmd->cmdAlias)))
+                    /* only compare the length of the command -1 (to avoid comparing the \0 */
+                    if (    (0 == strncmp(  inst->buffer,
+                                            cmd->cmd,
+                                            strlen(cmd->cmd)))
+                        ||  (0 == strncmp(  inst->buffer,
+                                            cmd->cmdAlias,
+                                            strlen(cmd->cmdAlias))))
                     {
                         inst->write("\r\n", 2u);