diff options
author | Martin Kosek <mkosek@redhat.com> | 2011-01-13 11:12:36 +0100 |
---|---|---|
committer | Simo Sorce <ssorce@redhat.com> | 2011-01-14 14:20:57 -0500 |
commit | 8173b8e375ea99d06773ea4de18fa2f32ddc1039 (patch) | |
tree | 1a2a0568ed3a3be1c2a31a8dc549b3ca31e1a50d /daemons/ipa-slapi-plugins/ipa-pwd-extop/ipapwd_common.c | |
parent | 7b5601eeb52f0eab55c5b5577f90b2ecc7f26dd9 (diff) | |
download | freeipa-8173b8e375ea99d06773ea4de18fa2f32ddc1039.tar.gz freeipa-8173b8e375ea99d06773ea4de18fa2f32ddc1039.tar.xz freeipa-8173b8e375ea99d06773ea4de18fa2f32ddc1039.zip |
Potential memory leaks in ipa-pwd-extop
This patch fixes several potential memory leaks in ipa-pwd-extop
SLAPI plugin.
Common function ipapwd_gen_hashes() now cleans after itself when
it fails. Other changes are local and self-explanatory.
https://fedorahosted.org/freeipa/ticket/715
Diffstat (limited to 'daemons/ipa-slapi-plugins/ipa-pwd-extop/ipapwd_common.c')
-rw-r--r-- | daemons/ipa-slapi-plugins/ipa-pwd-extop/ipapwd_common.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/daemons/ipa-slapi-plugins/ipa-pwd-extop/ipapwd_common.c b/daemons/ipa-slapi-plugins/ipa-pwd-extop/ipapwd_common.c index 2bc36c09e..3b5b3c8dc 100644 --- a/daemons/ipa-slapi-plugins/ipa-pwd-extop/ipapwd_common.c +++ b/daemons/ipa-slapi-plugins/ipa-pwd-extop/ipapwd_common.c @@ -74,12 +74,14 @@ static int new_ipapwd_encsalt(krb5_context krbctx, { struct ipapwd_encsalt *es; int nes, i; + int rc; for (i = 0; encsalts[i]; i++) /* count */ ; es = calloc(i + 1, sizeof(struct ipapwd_encsalt)); if (!es) { LOG_OOM(); - return LDAP_OPERATIONS_ERROR; + rc = LDAP_OPERATIONS_ERROR; + goto fail; } for (i = 0, nes = 0; encsalts[i]; i++) { @@ -93,7 +95,8 @@ static int new_ipapwd_encsalt(krb5_context krbctx, enc = strdup(encsalts[i]); if (!enc) { LOG_OOM(); - return LDAP_OPERATIONS_ERROR; + rc = LDAP_OPERATIONS_ERROR; + goto fail; } salt = strchr(enc, ':'); if (!salt) { @@ -133,6 +136,10 @@ static int new_ipapwd_encsalt(krb5_context krbctx, *num_es_types = nes; return LDAP_SUCCESS; + +fail: + free(es); + return rc; } static struct ipapwd_krbcfg *ipapwd_getConfig(void) |