mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -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;
|
krb5_error_code kerr;
|
||||||
int times;
|
int times;
|
||||||
int ret;
|
int ret;
|
||||||
int c;
|
int c, i;
|
||||||
|
|
||||||
for (c = 0; deref_attr_names[c]; c++) {
|
for (c = 0; deref_attr_names[c]; c++) {
|
||||||
/* count */ ;
|
/* count */ ;
|
||||||
}
|
}
|
||||||
|
|
||||||
ds = calloc(c, sizeof(LDAPDerefSpec));
|
ds = calloc(c+1, sizeof(LDAPDerefSpec));
|
||||||
if (!ds) {
|
if (!ds) {
|
||||||
return ENOMEM;
|
return ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (c = 0; deref_attr_names[c]; c++) {
|
for (i = 0; deref_attr_names[i]; i++) {
|
||||||
ds[c].derefAttr = deref_attr_names[c];
|
ds[i].derefAttr = deref_attr_names[i];
|
||||||
ds[c].attributes = deref_attrs;
|
ds[i].attributes = deref_attrs;
|
||||||
}
|
}
|
||||||
|
ds[c].derefAttr = NULL;
|
||||||
|
|
||||||
ret = ldap_create_deref_control_value(ipactx->lcontext, ds, &derefval);
|
ret = ldap_create_deref_control_value(ipactx->lcontext, ds, &derefval);
|
||||||
if (ret != LDAP_SUCCESS) {
|
if (ret != LDAP_SUCCESS) {
|
||||||
|
Loading…
Reference in New Issue
Block a user