Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
hdt: Avoid false-positive single command detection
Since commit 1697594, some commands are
said to be "nomodule" like "say".

This patch was adding a check if the nomodule flag was set but didn't
checked that the associated structure did exist leading to false
positive detection.

As a result, the commands were not executed meaning the CLI was unsuable
since ... 3 years.... *shame*

This commit simply avoid considering the nomodule flag if the structure
is not allocated
  • Loading branch information
ErwanAliasr1 committed Sep 4, 2015
1 parent 5c6e28d commit 87472a3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions com32/hdt/hdt-cli.c
Expand Up @@ -635,7 +635,7 @@ static void exec_command(char *line, struct s_hardware *hardware)
find_cli_callback_descr(command, current_mode->default_modules,
&current_module);

if ((module == NULL) || (current_module->nomodule == true)) {
if ((module == NULL) || ((current_module != NULL) && current_module->nomodule == true)) {
dprintf("CLI DEBUG exec : single command detected\n");
/*
* A single word was specified: look at the list of default
Expand All @@ -645,7 +645,7 @@ static void exec_command(char *line, struct s_hardware *hardware)
*/

/* First of all it the command doesn't need module, let's rework the arguments */
if ((current_module->nomodule == true) && ( module != NULL)) {
if (((current_module != NULL) && (current_module->nomodule == true)) && ( module != NULL)) {
dprintf("CLI_DEBUG exec: Reworking arguments with argc=%d\n",argc);
char **new_argv=NULL;
new_argv=malloc((argc + 2)*sizeof(char *));
Expand Down

0 comments on commit 87472a3

Please sign in to comment.