aboutsummaryrefslogtreecommitdiffstats
path: root/com32
diff options
context:
space:
mode:
authorErwan Velu <erwanaliasr1@gmail.com>2015-08-14 09:20:08 +0200
committerErwan Velu <erwanaliasr1@gmail.com>2015-09-04 17:57:44 +0200
commit5c6e28dc56ea03c9af557214801ab45f256cd981 (patch)
treec47e8aa956f79c32e3cdb479b72b0fc39d5cba50 /com32
parent8f17572be0a5a572f94bd476811087f634c26de6 (diff)
downloadsyslinux-5c6e28dc56ea03c9af557214801ab45f256cd981.tar.gz
syslinux-5c6e28dc56ea03c9af557214801ab45f256cd981.tar.xz
syslinux-5c6e28dc56ea03c9af557214801ab45f256cd981.zip
hdt: Fixing argv usage to avoid crash
argv shall be passed as a pointer to avoid a crash when running command like "dmi". Thanks genec for pointing this out.
Diffstat (limited to 'com32')
-rw-r--r--com32/hdt/hdt-cli.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/com32/hdt/hdt-cli.c b/com32/hdt/hdt-cli.c
index 776c8e8b..64f07bb9 100644
--- a/com32/hdt/hdt-cli.c
+++ b/com32/hdt/hdt-cli.c
@@ -322,7 +322,7 @@ out:
* command is always malloc'ed (even for an empty line)
**/
static void parse_command_line(char *line, char **command, char **module,
- int *argc, char **argv)
+ int *argc, char ***argv)
{
int argc_iter = 0, args_pos = 0, token_found = 0, token_len = 0;
int args_len = 0;
@@ -390,8 +390,8 @@ static void parse_command_line(char *line, char **command, char **module,
pch = strtok(line + args_pos, CLI_SPACE);
while (pch != NULL) {
dprintf("CLI DEBUG parse: argv[%d] = %s\n", argc_iter, pch);
- argv[argc_iter] = malloc(strlen(pch) * sizeof(char));
- strlcpy(argv[argc_iter], pch, strlen(pch));
+ *argv[argc_iter] = malloc(strlen(pch) * sizeof(char));
+ strlcpy(*argv[argc_iter], pch, strlen(pch));
argc_iter++;
pch = strtok(NULL, CLI_SPACE);
/*
@@ -582,7 +582,7 @@ static void autocomplete(char *line)
char *command = NULL, *module = NULL;
char **argv = NULL;
- parse_command_line(line, &command, &module, &argc, argv);
+ parse_command_line(line, &command, &module, &argc, &argv);
dprintf("CLI DEBUG autocomplete: before checking args\n");
/* If the user specified arguments, there is nothing we can complete */
@@ -623,7 +623,7 @@ static void exec_command(char *line, struct s_hardware *hardware)
struct cli_callback_descr *current_module = NULL;
/* This will allocate memory for command and module */
- parse_command_line(line, &command, &module, &argc, argv);
+ parse_command_line(line, &command, &module, &argc, &argv);
dprintf("CLI DEBUG exec: Checking for aliases\n");
/*