Exit on bad maxadmin arguments

The errors were detected but the code proceeded to call various functions
with bad pointers. This led to a crash if a bad server name was given to
'show server'.
This commit is contained in:
Markus Makela
2016-12-02 19:08:54 +02:00
parent a4bc575353
commit be7a315614

View File

@ -1755,6 +1755,7 @@ execute_cmd(CLI_SESSION *cli)
else else
{ {
unsigned long arg_list[MAXARGS] = {}; unsigned long arg_list[MAXARGS] = {};
bool ok = true;
for (int k = 0; k < cmds[i].options[j].argc_max && k < argc; k++) for (int k = 0; k < cmds[i].options[j].argc_max && k < argc; k++)
{ {
@ -1762,10 +1763,12 @@ execute_cmd(CLI_SESSION *cli)
if (arg_list[k] == 0) if (arg_list[k] == 0)
{ {
dcb_printf(dcb, "Invalid argument: %s\n", args[k + 2]); dcb_printf(dcb, "Invalid argument: %s\n", args[k + 2]);
break; ok = false;
} }
} }
if (ok)
{
switch (cmds[i].options[j].argc_max) switch (cmds[i].options[j].argc_max)
{ {
case 0: case 0:
@ -1832,6 +1835,7 @@ execute_cmd(CLI_SESSION *cli)
} }
} }
} }
}
if (!found) if (!found)
{ {
dcb_printf(dcb, dcb_printf(dcb,