summaryrefslogtreecommitdiffstats
path: root/daemons
diff options
context:
space:
mode:
authorSimo Sorce <ssorce@redhat.com>2012-03-20 09:47:52 -0400
committerMartin Kosek <mkosek@redhat.com>2012-03-22 17:33:24 +0100
commit5ffa1c70acf22dab1fea5d89474d91ec7df25068 (patch)
treeafd8205314f4ec3f3678baa8335ea94a03fe5cdb /daemons
parente770921ce65f8801fdd58311b31ecc9fbf57a474 (diff)
downloadfreeipa.git-5ffa1c70acf22dab1fea5d89474d91ec7df25068.tar.gz
freeipa.git-5ffa1c70acf22dab1fea5d89474d91ec7df25068.tar.xz
freeipa.git-5ffa1c70acf22dab1fea5d89474d91ec7df25068.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')
-rw-r--r--daemons/ipa-kdb/ipa_kdb_passwords.c3
-rw-r--r--daemons/ipa-kdb/ipa_kdb_principals.c3
-rw-r--r--daemons/ipa-kdb/ipa_kdb_pwdpolicy.c3
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 c717e203..b6520ea7 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 a0d46871..14326198 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 91de0342..a5438081 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;
}