Fix a bug in exec_interactive_command().
authorAndre Noll <maan@systemlinux.org>
Sat, 1 Nov 2008 21:18:58 +0000 (22:18 +0100)
committerAndre Noll <maan@systemlinux.org>
Sat, 1 Nov 2008 21:18:58 +0000 (22:18 +0100)
In case a command iwthout further options was given, p pointed one
byte after the malloced string, and this pointer is passed to the
command handler..

interactive.c

index 93e4a36b46e66a6481cc70afb91e562b0a26b5ff..191e6330f3989995ab93c42252f8a7f1d78ad2dd 100644 (file)
@@ -99,8 +99,12 @@ static int exec_interactive_command(char *line)
        char *p = cmd + strcspn(cmd, delim);
        int ret = -E_SYNTAX;
 
-       *p = '\0';
-       p++;
+       if (*p == '\0')
+               p = NULL;
+       else {
+               *p = '\0';
+               p++;
+       }
        for (i = 0; icmds[i].name; i++) {
                ERROR_LOG("name: %s, cmd: %s.\n", icmds[i].name, cmd);
                if (strcmp(icmds[i].name, cmd))