From c0a51fe0c8051e27c6cee4f4f0c705356a715e1e Mon Sep 17 00:00:00 2001 From: Greg Hudson Date: Thu, 20 Oct 2011 03:45:12 +0000 Subject: [PATCH] Fix krb5_cc_set_config krb5_cc_set_config has been non-functional since r24753 on cache types which don't support removal of credential entries. Fix it by only calling krb5_cc_remove_cred if data is NULL, since krb5_cc_store_cred will do it anyway in the positive case. Also fix an old memory leak in an uncommon error case. ticket: 6987 target_version: 1.10 tags: pullup git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@25384 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/krb5/ccache/ccfns.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/lib/krb5/ccache/ccfns.c b/src/lib/krb5/ccache/ccfns.c index 70c607dfb..b5a878fc6 100644 --- a/src/lib/krb5/ccache/ccfns.c +++ b/src/lib/krb5/ccache/ccfns.c @@ -281,16 +281,14 @@ krb5_cc_set_config(krb5_context context, krb5_ccache id, if (ret) goto out; - /* Remove old configuration */ - ret = krb5_cc_remove_cred(context, id, 0, &cred); - if (ret && ret != KRB5_CC_NOTFOUND) - goto out; - - if (data) { + if (data == NULL) { + ret = krb5_cc_remove_cred(context, id, 0, &cred); + } else { cred.ticket.data = malloc(data->length); if (cred.ticket.data == NULL) { - krb5_set_error_message(context, ENOMEM, "malloc: out of memory"); - return ENOMEM; + ret = ENOMEM; + krb5_set_error_message(context, ret, "malloc: out of memory"); + goto out; } cred.ticket.length = data->length; memcpy(cred.ticket.data, data->data, data->length); -- 2.26.2