[asterisk-commits] kmoore: branch 1.8 r396745 - in /branches/1.8/main: asterisk.c cli.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Aug 15 11:21:23 CDT 2013


Author: kmoore
Date: Thu Aug 15 11:21:20 2013
New Revision: 396745

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=396745
Log:
Remove leading spaces from the CLI command before parsing

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

Modified:
    branches/1.8/main/asterisk.c
    branches/1.8/main/cli.c

Modified: branches/1.8/main/asterisk.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/main/asterisk.c?view=diff&rev=396745&r1=396744&r2=396745
==============================================================================
--- branches/1.8/main/asterisk.c (original)
+++ branches/1.8/main/asterisk.c Thu Aug 15 11:21:20 2013
@@ -1943,6 +1943,10 @@
 			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);

Modified: branches/1.8/main/cli.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/main/cli.c?view=diff&rev=396745&r1=396744&r2=396745
==============================================================================
--- branches/1.8/main/cli.c (original)
+++ branches/1.8/main/cli.c Thu Aug 15 11:21:20 2013
@@ -2282,6 +2282,13 @@
 		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) {




More information about the asterisk-commits mailing list