Check to make sure the context is valid and return an error if it
authorTheodore Tso <tytso@mit.edu>
Fri, 12 Mar 1999 20:33:28 +0000 (20:33 +0000)
committerTheodore Tso <tytso@mit.edu>
Fri, 12 Mar 1999 20:33:28 +0000 (20:33 +0000)
isn't.

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@11273 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/krb5/os/ccdefname.c

index 18a7b998374b135290890c07decf26d0608a2665..fccdbf833122b387f3b3f554a5f72def749be674 100644 (file)
@@ -84,6 +84,9 @@ static krb5_error_code get_from_os(char *name_buf, int name_size)
        char *prefix = krb5_cc_dfl_ops->prefix;
        int len;
 
+       if (get_from_registry(name_buf, name_size) == 0)
+               return 0;
+
        if (!strcmp(prefix, "FILE") || !strcmp(prefix, "STDIO")) {
                GetWindowsDirectory (defname, sizeof(defname)-7);
                strcat (defname, "\\krb5cc");
@@ -129,6 +132,9 @@ krb5_cc_set_default_name(context, name)
        krb5_error_code retval;
        krb5_os_context os_ctx;
 
+       if (!context || context->magic != KV5M_CONTEXT)
+               return KV5M_CONTEXT;
+
        os_ctx = context->os_context;
        
        if (!name)
@@ -161,10 +167,12 @@ krb5_cc_default_name(context)
 {
        krb5_os_context os_ctx;
 
+       if (!context || context->magic != KV5M_CONTEXT)
+               return NULL;
+
        os_ctx = context->os_context;
        if (!os_ctx->default_ccname)
                krb5_cc_set_default_name(context, NULL);
 
        return(os_ctx->default_ccname);
 }
-