Always allocate a struct sudo_command for the command, even for ALL.

Previously we special-cased handling of ALL but this complicates
some upcoming changes.
This commit is contained in:
Todd C. Miller
2021-08-18 09:12:19 -06:00
parent dad40a50a1
commit 53a95e3a50
3 changed files with 241 additions and 250 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -617,14 +617,6 @@ digcmnd : opcmnd {
sudoerserror(N_("a digest requires a path name"));
YYERROR;
}
if (c == NULL) {
/* lazy-allocate sudo_command for ALL */
if ((c = new_command(NULL, NULL)) == NULL) {
sudoerserror(N_("unable to allocate memory"));
YYERROR;
}
$2->name = (char *)c;
}
parser_leak_remove(LEAK_DIGEST, $1);
HLTQ_TO_TAILQ(&c->digests, $1, entries);
$$ = $2;
@@ -919,7 +911,13 @@ cmndtag : /* empty */ {
;
cmnd : ALL {
$$ = new_member(NULL, ALL);
struct sudo_command *c;
if ((c = new_command(NULL, NULL)) == NULL) {
sudoerserror(N_("unable to allocate memory"));
YYERROR;
}
$$ = new_member((char *)c, ALL);
if ($$ == NULL) {
sudoerserror(N_("unable to allocate memory"));
YYERROR;

View File

@@ -396,11 +396,6 @@ cmnd_matches(struct sudoers_parse_tree *parse_tree, const struct member *m,
switch (m->type) {
case ALL:
if (m->name == NULL) {
matched = !m->negated;
break;
}
FALLTHROUGH;
case COMMAND:
c = (struct sudo_command *)m->name;
if (command_matches(c->cmnd, c->args, runchroot, info, &c->digests))