Fix maxadmin argument processing

The arguments were limited to a hard-coded value which wasn't what the
MAXARGS define stated.
This commit is contained in:
Markus Makela
2016-11-23 17:32:39 +02:00
parent e8af6908c1
commit 67c443fb51

View File

@ -1447,7 +1447,7 @@ execute_cmd(CLI_SESSION *cli)
args[0] = cli->cmdbuf; args[0] = cli->cmdbuf;
ptr = args[0]; ptr = args[0];
lptr = ptr; lptr = ptr;
i = 0; i = 1;
/* /*
* Break the command line into a number of words. Whitespace is used * Break the command line into a number of words. Whitespace is used
* to delimit words and may be escaped by use of the \ character or * to delimit words and may be escaped by use of the \ character or
@ -1455,7 +1455,7 @@ execute_cmd(CLI_SESSION *cli)
* The array args contains the broken down words, one per index. * The array args contains the broken down words, one per index.
*/ */
while (*ptr) while (*ptr && i <= MAXARGS + 2)
{ {
if (escape_next) if (escape_next)
{ {
@ -1479,19 +1479,7 @@ execute_cmd(CLI_SESSION *cli)
break; break;
} }
if (args[i] == ptr) args[i++] = ptr + 1;
{
args[i] = ptr + 1;
}
else
{
i++;
if (i >= MAXARGS - 1)
{
break;
}
args[i] = ptr + 1;
}
ptr++; ptr++;
lptr++; lptr++;
} }
@ -1513,14 +1501,13 @@ execute_cmd(CLI_SESSION *cli)
} }
} }
*lptr = 0; *lptr = 0;
args[MXS_MIN(MAXARGS - 1, i + 1)] = NULL; args[i] = NULL;
if (args[0] == NULL || *args[0] == 0) if (args[0] == NULL || *args[0] == 0)
{ {
return 1; return 1;
} }
for (i = 0; args[i] && *args[i]; i++)
;
argc = i - 2; /* The number of extra arguments to commands */ argc = i - 2; /* The number of extra arguments to commands */
if (!strcasecmp(args[0], "help")) if (!strcasecmp(args[0], "help"))
@ -1561,7 +1548,7 @@ execute_cmd(CLI_SESSION *cli)
dcb_printf(dcb, "Available options to the %s command:\n", args[1]); dcb_printf(dcb, "Available options to the %s command:\n", args[1]);
for (j = 0; cmds[i].options[j].arg1; j++) for (j = 0; cmds[i].options[j].arg1; j++)
{ {
dcb_printf(dcb, "'%s' - %s\n\n\t%s\n\n", cmds[i].options[j].arg1, dcb_printf(dcb, "'%s' - %s\n\n%s\n\n", cmds[i].options[j].arg1,
cmds[i].options[j].help, cmds[i].options[j].devhelp); cmds[i].options[j].help, cmds[i].options[j].devhelp);
} }