2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-31 06:15:37 +00:00

Use an iterator instead of fragile pointer arithmetic to iterate

over value arrays in sudo_ldap_role_to_priv().
This commit is contained in:
Todd C. Miller
2018-02-09 22:06:56 -07:00
parent 64e99328e3
commit 4459ee42ed
4 changed files with 41 additions and 20 deletions

View File

@@ -2311,6 +2311,16 @@ sudo_ldap_display_bound_defaults(struct sudo_nss *nss, struct passwd *pw,
debug_return_int(0);
}
static char *
berval_iter(void *base, void **save)
{
struct berval **bv;
bv = *save ? *save : base;
*save = bv + 1;
return *bv ? (*bv)->bv_val : NULL;
}
static struct userspec_list *
ldap_to_sudoers(LDAP *ld, struct ldap_result *lres)
{
@@ -2368,8 +2378,7 @@ ldap_to_sudoers(LDAP *ld, struct ldap_result *lres)
priv = sudo_ldap_role_to_priv(cn, runasusers, runasgroups,
cmnds, opts, notbefore ? notbefore[0]->bv_val : NULL,
notafter ? notafter[0]->bv_val : NULL,
sizeof(struct berval *), offsetof(struct berval, bv_val));
notafter ? notafter[0]->bv_val : NULL, berval_iter);
/* Cleanup */
if (cn != NULL)