pull up r20551 from trunk
authorTom Yu <tlyu@mit.edu>
Mon, 21 Jul 2008 22:59:28 +0000 (22:59 +0000)
committerTom Yu <tlyu@mit.edu>
Mon, 21 Jul 2008 22:59:28 +0000 (22:59 +0000)
 r20551@cathode-dark-space:  jaltman | 2008-07-21 13:44:43 -0400
 ticket: 5080
 tags: pullup

 ccdefault.c:
 krb5_cc_default_name() is permitted to return a NULL
 pointer as a valid output.  Passing a NULL pointer to
 strcmp() will result in an exception as NULL is not
 a valid input parameter to strcmp().

 Save the output of krb5_cc_default_name() to a variable
 and modify the conditional to set the new default ccache
 name in the case where there is no existing default
 ccache name.

ticket: 5980

git-svn-id: svn://anonsvn.mit.edu/krb5/branches/krb5-1-6@20564 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/krb5/ccache/ccdefault.c

index d36b104749aa993556ec07419c75c18b184e0765..9481d59127a9563e34f001adf954d933f66c4bba 100644 (file)
@@ -82,7 +82,8 @@ krb5int_cc_default(krb5_context context, krb5_ccache *ccache)
             /* This function tries to get tickets and put them in the specified 
             cache, however, if the cache does not exist, it may choose to put 
             them elsewhere (ie: the system default) so we set that here */
-            if (strcmp (krb5_cc_default_name (context), outCacheName) != 0) {
+            char * ccdefname = krb5_cc_default_name (context);
+            if (!ccdefname || strcmp (ccdefname, outCacheName) != 0) {
                 krb5_cc_set_default_name (context, outCacheName);
             }
             KLDisposeString (outCacheName);
@@ -102,7 +103,8 @@ krb5int_cc_default(krb5_context context, krb5_ccache *ccache)
        char ccname[256]="";
         pLeash_AcquireInitialTicketsIfNeeded(context, NULL, ccname, sizeof(ccname));
        if (ccname[0]) {
-            if (strcmp (krb5_cc_default_name (context),ccname) != 0) {
+            char * ccdefname = krb5_cc_default_name (context);
+            if (!ccdefname || strcmp (ccdefname, ccname) != 0) {
                 krb5_cc_set_default_name (context, ccname);
             }
        }