mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-01-28 09:06:44 -06:00
ipa-kdb: add sentinel for LDAPDerefSpec allocation
Without sentinel in place, ldap_create_deref_control_value executed an invalid read in unallocated memory.
This commit is contained in:
parent
67d8b434c5
commit
e234edc995
@ -282,21 +282,22 @@ krb5_error_code ipadb_deref_search(struct ipadb_context *ipactx,
|
||||
krb5_error_code kerr;
|
||||
int times;
|
||||
int ret;
|
||||
int c;
|
||||
int c, i;
|
||||
|
||||
for (c = 0; deref_attr_names[c]; c++) {
|
||||
/* count */ ;
|
||||
}
|
||||
|
||||
ds = calloc(c, sizeof(LDAPDerefSpec));
|
||||
ds = calloc(c+1, sizeof(LDAPDerefSpec));
|
||||
if (!ds) {
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
for (c = 0; deref_attr_names[c]; c++) {
|
||||
ds[c].derefAttr = deref_attr_names[c];
|
||||
ds[c].attributes = deref_attrs;
|
||||
for (i = 0; deref_attr_names[i]; i++) {
|
||||
ds[i].derefAttr = deref_attr_names[i];
|
||||
ds[i].attributes = deref_attrs;
|
||||
}
|
||||
ds[c].derefAttr = NULL;
|
||||
|
||||
ret = ldap_create_deref_control_value(ipactx->lcontext, ds, &derefval);
|
||||
if (ret != LDAP_SUCCESS) {
|
||||
|
Loading…
Reference in New Issue
Block a user