* 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 <raeburn@mit.edu>
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) {