Add reference counting to Defaults bindings.
Previously, we checked that the previous entry's binding pointer was not the same while freeing. However, to be able to merge Defaults records we cannot rely on Defaults entries with the same binding being immediately adjacent. This removes the prev_binding checks in favor of a reference count which allows us to plug the memory leak in cvtsudoers when merging Defaults.
This commit is contained in:
@@ -714,19 +714,19 @@ default_binding_matches(struct sudoers_parse_tree *parse_tree,
|
||||
case DEFAULTS:
|
||||
debug_return_bool(true);
|
||||
case DEFAULTS_USER:
|
||||
if (userlist_matches(parse_tree, sudo_user.pw, d->binding) == ALLOW)
|
||||
if (userlist_matches(parse_tree, sudo_user.pw, &d->binding->members) == ALLOW)
|
||||
debug_return_bool(true);
|
||||
break;
|
||||
case DEFAULTS_RUNAS:
|
||||
if (runaslist_matches(parse_tree, d->binding, NULL, NULL, NULL) == ALLOW)
|
||||
if (runaslist_matches(parse_tree, &d->binding->members, NULL, NULL, NULL) == ALLOW)
|
||||
debug_return_bool(true);
|
||||
break;
|
||||
case DEFAULTS_HOST:
|
||||
if (hostlist_matches(parse_tree, sudo_user.pw, d->binding) == ALLOW)
|
||||
if (hostlist_matches(parse_tree, sudo_user.pw, &d->binding->members) == ALLOW)
|
||||
debug_return_bool(true);
|
||||
break;
|
||||
case DEFAULTS_CMND:
|
||||
if (cmndlist_matches(parse_tree, d->binding, NULL, NULL) == ALLOW)
|
||||
if (cmndlist_matches(parse_tree, &d->binding->members, NULL, NULL) == ALLOW)
|
||||
debug_return_bool(true);
|
||||
break;
|
||||
}
|
||||
|
Reference in New Issue
Block a user