Fix ressource leak in daemons/ipa-slapi-plugins/ipa-cldap/ipa_cldap_netlogon.c ipa_cldap_netlogon

The leak happens due to using strndup in a for loop to create a temporary
string without freeing it in all cases.

See: https://pagure.io/freeipa/issue/7738
Signed-off-by: Thomas Woerner <twoerner@redhat.com>
Reviewed-By: Christian Heimes <cheimes@redhat.com>
This commit is contained in:
Thomas Woerner 2018-10-22 15:18:23 +02:00 committed by Christian Heimes
parent 389c17c5c6
commit 8e98c72e51

View File

@ -260,6 +260,10 @@ int ipa_cldap_netlogon(struct ipa_cldap_ctx *ctx,
if (req->kvps.pairs[i].value.bv_val[len-1] == '.') { if (req->kvps.pairs[i].value.bv_val[len-1] == '.') {
len--; len--;
} }
if (domain != NULL) {
free(domain);
domain = NULL;
}
domain = strndup(req->kvps.pairs[i].value.bv_val, len); domain = strndup(req->kvps.pairs[i].value.bv_val, len);
if (!domain) { if (!domain) {
ret = ENOMEM; ret = ENOMEM;