mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
ipa-sam: do not leak LDAPMessage on ipa-sam initialization
We used to handle some of code paths to free memory allocated by the LDAP library but there are few more unhandled. In addition, search result wasn't freed on successful initialization, leaking for long time. https://fedorahosted.org/freeipa/ticket/3913
This commit is contained in:
committed by
Petr Viktorin
parent
9cf8ec79c9
commit
860a3ff647
@@ -4273,6 +4273,7 @@ static NTSTATUS pdb_init_ipasam(struct pdb_methods **pdb_method,
|
|||||||
if (ldap_state->ipasam_privates->flat_name == NULL) {
|
if (ldap_state->ipasam_privates->flat_name == NULL) {
|
||||||
DEBUG(0, ("Missing mandatory attribute %s.\n",
|
DEBUG(0, ("Missing mandatory attribute %s.\n",
|
||||||
LDAP_ATTRIBUTE_FLAT_NAME));
|
LDAP_ATTRIBUTE_FLAT_NAME));
|
||||||
|
ldap_msgfree(result);
|
||||||
return NT_STATUS_INVALID_PARAMETER;
|
return NT_STATUS_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4280,8 +4281,9 @@ static NTSTATUS pdb_init_ipasam(struct pdb_methods **pdb_method,
|
|||||||
idmap_talloc_free,
|
idmap_talloc_free,
|
||||||
&ldap_state->ipasam_privates->idmap_ctx);
|
&ldap_state->ipasam_privates->idmap_ctx);
|
||||||
if (err != IDMAP_SUCCESS) {
|
if (err != IDMAP_SUCCESS) {
|
||||||
DEBUG(1, ("Failed to setup idmap context.\n"));
|
DEBUG(1, ("Failed to setup idmap context.\n"));
|
||||||
return NT_STATUS_UNSUCCESSFUL;
|
ldap_msgfree(result);
|
||||||
|
return NT_STATUS_UNSUCCESSFUL;
|
||||||
}
|
}
|
||||||
|
|
||||||
fallback_group_sid = get_fallback_group_sid(ldap_state,
|
fallback_group_sid = get_fallback_group_sid(ldap_state,
|
||||||
@@ -4290,6 +4292,7 @@ static NTSTATUS pdb_init_ipasam(struct pdb_methods **pdb_method,
|
|||||||
result);
|
result);
|
||||||
if (fallback_group_sid == NULL) {
|
if (fallback_group_sid == NULL) {
|
||||||
DEBUG(0, ("Cannot find SID of fallback group.\n"));
|
DEBUG(0, ("Cannot find SID of fallback group.\n"));
|
||||||
|
ldap_msgfree(result);
|
||||||
return NT_STATUS_INVALID_PARAMETER;
|
return NT_STATUS_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
sid_copy(&ldap_state->ipasam_privates->fallback_primary_group,
|
sid_copy(&ldap_state->ipasam_privates->fallback_primary_group,
|
||||||
@@ -4319,10 +4322,12 @@ static NTSTATUS pdb_init_ipasam(struct pdb_methods **pdb_method,
|
|||||||
|
|
||||||
status = save_sid_to_secret(ldap_state);
|
status = save_sid_to_secret(ldap_state);
|
||||||
if (!NT_STATUS_IS_OK(status)) {
|
if (!NT_STATUS_IS_OK(status)) {
|
||||||
|
ldap_msgfree(result);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ldap_msgfree(result);
|
||||||
(*pdb_method)->getsampwnam = ldapsam_getsampwnam;
|
(*pdb_method)->getsampwnam = ldapsam_getsampwnam;
|
||||||
(*pdb_method)->search_users = ldapsam_search_users;
|
(*pdb_method)->search_users = ldapsam_search_users;
|
||||||
(*pdb_method)->search_groups = ldapsam_search_groups;
|
(*pdb_method)->search_groups = ldapsam_search_groups;
|
||||||
|
|||||||
Reference in New Issue
Block a user