From 8e7041782c3e711b8f40fb99f4422f6764ca4a1f Mon Sep 17 00:00:00 2001 From: Theodore Tso Date: Mon, 7 Aug 1995 23:20:23 +0000 Subject: [PATCH] If there is an error looking up the key, make sure the keytab is closed as part of the cleanup. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@6445 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/krb5/krb/ChangeLog | 6 ++++++ src/lib/krb5/krb/in_tkt_ktb.c | 15 +++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/lib/krb5/krb/ChangeLog b/src/lib/krb5/krb/ChangeLog index e40af558e..a74b6eb35 100644 --- a/src/lib/krb5/krb/ChangeLog +++ b/src/lib/krb5/krb/ChangeLog @@ -1,3 +1,9 @@ +Mon Aug 7 18:54:35 1995 Theodore Y. Ts'o + + * in_tkt_ktb.c (keytab_keyproc): If there is an error looking up + the key, make sure the keytab is closed as part of the + cleanup. + Fri Aug 4 22:04:08 1995 Tom Yu * conv_princ.c: Add braces to initializer to shut up gcc -Wall diff --git a/src/lib/krb5/krb/in_tkt_ktb.c b/src/lib/krb5/krb/in_tkt_ktb.c index 9cf295e83..2a96b1160 100644 --- a/src/lib/krb5/krb/in_tkt_ktb.c +++ b/src/lib/krb5/krb/in_tkt_ktb.c @@ -54,7 +54,7 @@ keytab_keyproc(context, type, salt, keyseed, key) { struct keytab_keyproc_arg * arg = (struct keytab_keyproc_arg *)keyseed; krb5_keyblock *realkey; - krb5_error_code retval; + krb5_error_code retval = 0; krb5_keytab kt_id; krb5_keytab_entry kt_ent; @@ -72,24 +72,27 @@ keytab_keyproc(context, type, salt, keyseed, key) if ((retval = krb5_kt_get_entry(context, kt_id, arg->client, 0, /* don't have vno available */ type, &kt_ent))) - return retval; + goto cleanup; if ((retval = krb5_copy_keyblock(context, &kt_ent.key, &realkey))) { (void) krb5_kt_free_entry(context, &kt_ent); - return retval; + goto cleanup; } if (realkey->keytype != type) { (void) krb5_kt_free_entry(context, &kt_ent); krb5_free_keyblock(context, realkey); - return KRB5_PROG_ETYPE_NOSUPP; + retval = KRB5_PROG_ETYPE_NOSUPP; + goto cleanup; } (void) krb5_kt_free_entry(context, &kt_ent); + *key = realkey; + +cleanup: if (arg->keytab) krb5_kt_close(context, kt_id); - *key = realkey; - return 0; + return retval; } /* -- 2.26.2