From 735618a1c6aee05d1c6455320da46fc52c85ca8c Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Tue, 20 Mar 2012 09:47:52 -0400 Subject: 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 --- daemons/ipa-kdb/ipa_kdb_passwords.c | 3 +++ daemons/ipa-kdb/ipa_kdb_principals.c | 3 +++ daemons/ipa-kdb/ipa_kdb_pwdpolicy.c | 3 +++ 3 files changed, 9 insertions(+) (limited to 'daemons/ipa-kdb') 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; } -- cgit