diff options
author | Simo Sorce <ssorce@redhat.com> | 2012-03-20 09:47:52 -0400 |
---|---|---|
committer | Martin Kosek <mkosek@redhat.com> | 2012-03-22 17:33:13 +0100 |
commit | 735618a1c6aee05d1c6455320da46fc52c85ca8c (patch) | |
tree | 8e28717668d2892a5ba4474a5d2c86fd5da7a96c /daemons/ipa-kdb | |
parent | 19b2af8e52d772aaba190beb747fc2e87821fdbe (diff) | |
download | freeipa-735618a1c6aee05d1c6455320da46fc52c85ca8c.tar.gz freeipa-735618a1c6aee05d1c6455320da46fc52c85ca8c.tar.xz freeipa-735618a1c6aee05d1c6455320da46fc52c85ca8c.zip |
Fix memleak and silence Coverity defects
Some of these are not real defects, because we are guaranteed to have valid
context in some functions, and checks are not necessary.
I added the checks anyway in order to silence Coverity on these issues.
One meleak on error condition was fixed in
daemons/ipa-kdb/ipa_kdb_pwdpolicy.c
Silence errors in ipa-client/ipa-getkeytab.c, the code looks wrong, but it is
actually fine as we count before hand so we never actually use the wrong value
that is computed on the last pass when p == 0
Fixes: https://fedorahosted.org/freeipa/ticket/2488
Diffstat (limited to 'daemons/ipa-kdb')
-rw-r--r-- | daemons/ipa-kdb/ipa_kdb_passwords.c | 3 | ||||
-rw-r--r-- | daemons/ipa-kdb/ipa_kdb_principals.c | 3 | ||||
-rw-r--r-- | daemons/ipa-kdb/ipa_kdb_pwdpolicy.c | 3 |
3 files changed, 9 insertions, 0 deletions
diff --git a/daemons/ipa-kdb/ipa_kdb_passwords.c b/daemons/ipa-kdb/ipa_kdb_passwords.c index c717e2031..b6520ea75 100644 --- a/daemons/ipa-kdb/ipa_kdb_passwords.c +++ b/daemons/ipa-kdb/ipa_kdb_passwords.c @@ -71,6 +71,9 @@ static krb5_error_code ipadb_check_pw_policy(krb5_context context, int ret; ipactx = ipadb_get_context(context); + if (!ipactx) { + return KRB5_KDB_DBNOTINITED; + } ied = (struct ipadb_e_data *)db_entry->e_data; if (ied->magic != IPA_E_DATA_MAGIC) { diff --git a/daemons/ipa-kdb/ipa_kdb_principals.c b/daemons/ipa-kdb/ipa_kdb_principals.c index a0d468717..143261982 100644 --- a/daemons/ipa-kdb/ipa_kdb_principals.c +++ b/daemons/ipa-kdb/ipa_kdb_principals.c @@ -373,6 +373,9 @@ static krb5_error_code ipadb_parse_ldap_entry(krb5_context kcontext, /* proceed to fill in attributes in the order they are defined in * krb5_db_entry in kdb.h */ ipactx = ipadb_get_context(kcontext); + if (!ipactx) { + return KRB5_KDB_DBNOTINITED; + } lcontext = ipactx->lcontext; entry->magic = KRB5_KDB_MAGIC_NUMBER; diff --git a/daemons/ipa-kdb/ipa_kdb_pwdpolicy.c b/daemons/ipa-kdb/ipa_kdb_pwdpolicy.c index 91de0342b..a54380815 100644 --- a/daemons/ipa-kdb/ipa_kdb_pwdpolicy.c +++ b/daemons/ipa-kdb/ipa_kdb_pwdpolicy.c @@ -121,6 +121,9 @@ krb5_error_code ipadb_get_ipapwd_policy(struct ipadb_context *ipactx, done: ldap_msgfree(res); + if (kerr) { + free(pol); + } return kerr; } |