]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Remove leading spaces from the CLI command before parsing
authorKinsey Moore <kmoore@digium.com>
Thu, 15 Aug 2013 16:21:20 +0000 (16:21 +0000)
committerKinsey Moore <kmoore@digium.com>
Thu, 15 Aug 2013 16:21:20 +0000 (16:21 +0000)
If you've mistakenly put a space before typing in a command, the
leading space will be included as part of the command, and the command
parser will not find the corresponding command. This patch rectifies
that situation by stripping the leading spaces on commands.

Review: https://reviewboard.asterisk.org/r/2709/
Patch-by: Tilghman Lesher
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@396745 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/asterisk.c
main/cli.c

index adf44be94152851893e27962cd07a1990449c03c..e164a3ff94e3887e735b0c7961115f00754e05c2 100644 (file)
@@ -1943,6 +1943,10 @@ static int remoteconsolehandler(char *s)
                        ast_safe_system(getenv("SHELL") ? getenv("SHELL") : "/bin/sh");
                ret = 1;
        }
+       while (isspace(*s)) {
+               s++;
+       }
+
        if ((strncasecmp(s, "quit", 4) == 0 || strncasecmp(s, "exit", 4) == 0) &&
            (s[4] == '\0' || isspace(s[4]))) {
                quit_handler(0, SHUTDOWN_FAST, 0);
index 751974485d1fb1a5bedbb7e969f8c36548533594..a8533857eb06d0ca6532d7c62fa7f9a9eb187c31 100644 (file)
@@ -2282,6 +2282,13 @@ static char *parse_args(const char *s, int *argc, const char *argv[], int max, i
                return NULL;
 
        cur = duplicate;
+
+       /* Remove leading spaces from the command */
+       while (isspace(*s)) {
+               cur++;
+               s++;
+       }
+
        /* scan the original string copying into cur when needed */
        for (; *s ; s++) {
                if (x >= max - 1) {