ddb: reliably fail with ambiguous commands

db_cmd_match had an even/odd bug, where if a third command was partially
matched (or any odd number greater than one) the search result would be
set back from CMD_AMBIGUOUS to CMD_FOUND, causing the last command in
the list to be executed instead of failing the match.

Reported by:	mlaier
Reviewed by:	markj, mlaier, vangyzen
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D28659
This commit is contained in:
Ryan Libby 2021-02-24 15:56:16 -08:00
parent 14b5a3c7d5
commit d85c9cef13

View File

@ -293,7 +293,7 @@ db_cmd_match(char *name, struct command *cmd, struct command **cmdp,
*resultp = CMD_AMBIGUOUS;
/* but keep looking for a full match -
this lets us match single letters */
} else {
} else if (*resultp == CMD_NONE) {
*cmdp = cmd;
*resultp = CMD_FOUND;
}