From 0371b3c42e1a5accaef8a8b1ecea1f7350a95c8e Mon Sep 17 00:00:00 2001 From: Ken Raeburn Date: Thu, 29 Jul 2004 01:48:05 +0000 Subject: [PATCH] * gssapi_krb5.c (kg_get_ccache_name): Make the copy always, not just in the local-context case. Check for errors in making the copy. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@16628 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/gssapi/krb5/ChangeLog | 2 ++ src/lib/gssapi/krb5/gssapi_krb5.c | 36 +++++++++++++++++-------------- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/src/lib/gssapi/krb5/ChangeLog b/src/lib/gssapi/krb5/ChangeLog index e18658f3a..c5f78eb3f 100644 --- a/src/lib/gssapi/krb5/ChangeLog +++ b/src/lib/gssapi/krb5/ChangeLog @@ -2,6 +2,8 @@ * gssapi_krb5.c (kg_get_ccache_name): Make a copy of the default ccache name, because calling krb5_free_context will destroy it. + Make the copy always, not just in the local-context case. Check + for errors in making the copy. 2004-07-14 Ken Raeburn diff --git a/src/lib/gssapi/krb5/gssapi_krb5.c b/src/lib/gssapi/krb5/gssapi_krb5.c index de5f50c24..e6f88a346 100644 --- a/src/lib/gssapi/krb5/gssapi_krb5.c +++ b/src/lib/gssapi/krb5/gssapi_krb5.c @@ -178,24 +178,28 @@ kg_get_ccache_name (OM_uint32 *minor_status, const char **out_name) const char *name = NULL; OM_uint32 err = 0; - if (!err) { - if (kg_ccache_name != NULL) { - name = kg_ccache_name; - } else { - krb5_context context = NULL; - - /* Reset the context default ccache (see text above), and - then retrieve it. */ - err = krb5_init_context(&context); - if (!err) - err = krb5_cc_set_default_name (context, NULL); - if (!err) { - name = krb5_cc_default_name(context); + if (kg_ccache_name != NULL) { + name = strdup(kg_ccache_name); + if (name == NULL) + err = errno; + } else { + krb5_context context = NULL; + + /* Reset the context default ccache (see text above), and then + retrieve it. */ + err = krb5_init_context(&context); + if (!err) + err = krb5_cc_set_default_name (context, NULL); + if (!err) { + name = krb5_cc_default_name(context); + if (name) { name = strdup(name); + if (name == NULL) + err = errno; } - if (context) - krb5_free_context(context); - } + } + if (context) + krb5_free_context(context); } if (!err) { -- 2.26.2