]> 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:29:56 +0000 (16:29 +0000)
committerKinsey Moore <kmoore@digium.com>
Thu, 15 Aug 2013 16:29:56 +0000 (16:29 +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
........

Merged revisions 396745 from http://svn.asterisk.org/svn/asterisk/branches/1.8

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/11@396746 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/asterisk.c
main/cli.c

index a734897b9700947651de5644150909fcf69a6d33..4493445aec506a5d1e93b6801c6b203cf43c7711 100644 (file)
@@ -1977,6 +1977,11 @@ static int remoteconsolehandler(char *s)
        /* Called when readline data is available */
        if (!ast_all_zeros(s))
                ast_el_add_history(s);
+
+       while (isspace(*s)) {
+               s++;
+       }
+
        /* The real handler for bang */
        if (s[0] == '!') {
                if (s[1])
index d64fd14360f2f586bbcba3c77e5dda42cc4be801..5e6263d386f80ed9d827ffe9e8c04d0b79bf6a17 100644 (file)
@@ -2299,6 +2299,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) {