[syslinux:master] hdt: Fixing argv usage to avoid crash

syslinux-bot for Erwan Velu erwanaliasr1 at gmail.com
Fri Sep 4 09:15:04 PDT 2015


Commit-ID:  5c6e28dc56ea03c9af557214801ab45f256cd981
Gitweb:     http://www.syslinux.org/commit/5c6e28dc56ea03c9af557214801ab45f256cd981
Author:     Erwan Velu <erwanaliasr1 at gmail.com>
AuthorDate: Fri, 14 Aug 2015 09:20:08 +0200
Committer:  Erwan Velu <erwanaliasr1 at gmail.com>
CommitDate: Fri, 4 Sep 2015 17:57:44 +0200

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.

---
 com32/hdt/hdt-cli.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/com32/hdt/hdt-cli.c b/com32/hdt/hdt-cli.c
index 776c8e8..64f07bb 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");
     /*


More information about the Syslinux-commits mailing list