diff options
author | Greg Hudson <ghudson@mit.edu> | 2013-02-28 18:55:31 -0500 |
---|---|---|
committer | Greg Hudson <ghudson@mit.edu> | 2013-02-28 18:56:37 -0500 |
commit | a39af2971e03d3dc6da2cfd8959feebd40a0ffc0 (patch) | |
tree | 06ab65d7468122d0853d463c78c9a00b2c07109a | |
parent | 8df7b929c3ee272e8255d57720c3e299ebccd198 (diff) | |
download | krb5-a39af2971e03d3dc6da2cfd8959feebd40a0ffc0.tar.gz krb5-a39af2971e03d3dc6da2cfd8959feebd40a0ffc0.tar.xz krb5-a39af2971e03d3dc6da2cfd8959feebd40a0ffc0.zip |
Fix a memory leak in krb5_get_init_creds_keytab
lookup_etypes_for_keytab was not freeing the keytab entries it
iterated over. Reported by nalin@redhat.com.
ticket: 7586
target_version: 1.11.2
tags: pullup
-rw-r--r-- | src/lib/krb5/krb/gic_keytab.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/lib/krb5/krb/gic_keytab.c b/src/lib/krb5/krb/gic_keytab.c index 3dca07385c..ff26c1832a 100644 --- a/src/lib/krb5/krb/gic_keytab.c +++ b/src/lib/krb5/krb/gic_keytab.c @@ -109,22 +109,29 @@ lookup_etypes_for_keytab(krb5_context context, krb5_keytab keytab, if (ret) goto cleanup; - if (!krb5_c_valid_enctype(entry.key.enctype)) + if (!krb5_c_valid_enctype(entry.key.enctype)) { + krb5_free_keytab_entry_contents(context, &entry); continue; - if (!krb5_principal_compare(context, entry.principal, client)) + } + if (!krb5_principal_compare(context, entry.principal, client)) { + krb5_free_keytab_entry_contents(context, &entry); continue; + } /* Make sure our list is for the highest kvno found for client. */ if (entry.vno > max_kvno) { free(etypes); etypes = NULL; count = 0; max_kvno = entry.vno; - } else if (entry.vno != max_kvno) + } else if (entry.vno != max_kvno) { + krb5_free_keytab_entry_contents(context, &entry); continue; + } /* Leave room for the terminator and possibly a second entry. */ p = realloc(etypes, (count + 3) * sizeof(*etypes)); if (p == NULL) { + krb5_free_keytab_entry_contents(context, &entry); ret = ENOMEM; goto cleanup; } @@ -136,6 +143,7 @@ lookup_etypes_for_keytab(krb5_context context, krb5_keytab keytab, entry.key.enctype == ENCTYPE_DES_CBC_MD4) etypes[count++] = ENCTYPE_DES_CBC_CRC; etypes[count] = 0; + krb5_free_keytab_entry_contents(context, &entry); } ret = 0; |