From 05ca118e24833244cb7b51da82720448baf12c99 Mon Sep 17 00:00:00 2001 From: Greg Hudson Date: Mon, 3 Nov 2008 19:47:40 +0000 Subject: [PATCH] Apply a patch from Apple to correct a few memory leaks ticket: 6201 git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@20958 dc483132-0cff-0310-8789-dd5450dbe970 --- src/kdc/kdc_authdata.c | 7 ++----- src/kdc/kdc_preauth.c | 7 ++----- src/lib/kdb/kdb_default.c | 11 +++++++++-- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/kdc/kdc_authdata.c b/src/kdc/kdc_authdata.c index a8f9241ea..9fd37f2d6 100644 --- a/src/kdc/kdc_authdata.c +++ b/src/kdc/kdc_authdata.c @@ -140,20 +140,17 @@ static struct plugin_dir_handle authdata_plugins; krb5_error_code load_authdata_plugins(krb5_context context) { - struct errinfo err; void **authdata_plugins_ftables = NULL; struct krb5plugin_authdata_ftable_v0 *ftable = NULL; size_t module_count; int i, k; init_proc server_init_proc = NULL; - memset(&err, 0, sizeof(err)); - /* Attempt to load all of the authdata plugins we can find. */ PLUGIN_DIR_INIT(&authdata_plugins); if (PLUGIN_DIR_OPEN(&authdata_plugins) == 0) { if (krb5int_open_plugin_dirs(objdirs, NULL, - &authdata_plugins, &err) != 0) { + &authdata_plugins, &context->err) != 0) { return KRB5_PLUGIN_NO_HANDLE; } } @@ -163,7 +160,7 @@ load_authdata_plugins(krb5_context context) n_authdata_systems = 0; if (krb5int_get_plugin_dir_data(&authdata_plugins, "authdata_server_0", - &authdata_plugins_ftables, &err) != 0) { + &authdata_plugins_ftables, &context->err) != 0) { return KRB5_PLUGIN_NO_HANDLE; } diff --git a/src/kdc/kdc_preauth.c b/src/kdc/kdc_preauth.c index 9fd8d8d98..c7655ab0d 100644 --- a/src/kdc/kdc_preauth.c +++ b/src/kdc/kdc_preauth.c @@ -321,7 +321,6 @@ static struct plugin_dir_handle preauth_plugins; krb5_error_code load_preauth_plugins(krb5_context context) { - struct errinfo err; void **preauth_plugins_ftables; struct krb5plugin_preauth_server_ftable_v1 *ftable; int module_count, i, j, k; @@ -329,13 +328,11 @@ load_preauth_plugins(krb5_context context) preauth_server_init_proc server_init_proc = NULL; char **kdc_realm_names = NULL; - memset(&err, 0, sizeof(err)); - /* Attempt to load all of the preauth plugins we can find. */ PLUGIN_DIR_INIT(&preauth_plugins); if (PLUGIN_DIR_OPEN(&preauth_plugins) == 0) { if (krb5int_open_plugin_dirs(objdirs, NULL, - &preauth_plugins, &err) != 0) { + &preauth_plugins, &context->err) != 0) { return KRB5_PLUGIN_NO_HANDLE; } } @@ -344,7 +341,7 @@ load_preauth_plugins(krb5_context context) preauth_plugins_ftables = NULL; if (krb5int_get_plugin_dir_data(&preauth_plugins, "preauthentication_server_1", - &preauth_plugins_ftables, &err) != 0) { + &preauth_plugins_ftables, &context->err) != 0) { return KRB5_PLUGIN_NO_HANDLE; } diff --git a/src/lib/kdb/kdb_default.c b/src/lib/kdb/kdb_default.c index f7a855b72..78d06a300 100644 --- a/src/lib/kdb/kdb_default.c +++ b/src/lib/kdb/kdb_default.c @@ -145,7 +145,7 @@ krb5_def_store_mkey(krb5_context context, char *tmp_ktname = NULL, *tmp_ktpath; krb5_data *realm = krb5_princ_realm(context, mname); #ifndef LEAN_CLIENT - krb5_keytab kt; + krb5_keytab kt = NULL; krb5_keytab_entry new_entry; #endif /* LEAN_CLIENT */ struct stat stb; @@ -226,6 +226,10 @@ krb5_def_store_mkey(krb5_context context, out: if (tmp_ktname != NULL) free(tmp_ktname); +#ifndef LEAN_CLIENT + if (kt) + krb5_kt_close(context, kt); +#endif return retval; } @@ -319,7 +323,7 @@ krb5_db_def_fetch_mkey_keytab(krb5_context context, krb5_kvno *kvno) { krb5_error_code retval = 0; - krb5_keytab kt; + krb5_keytab kt = NULL; krb5_keytab_entry kt_ent; krb5_enctype enctype = IGNORE_ENCTYPE; @@ -369,6 +373,9 @@ krb5_db_def_fetch_mkey_keytab(krb5_context context, } errout: + if (kt) + krb5_kt_close(context, kt); + return retval; } #endif /* LEAN_CLIENT */ -- 2.26.2