From: Jeffrey Altman Date: Mon, 21 Jul 2008 17:44:43 +0000 (+0000) Subject: ccdefault.c: X-Git-Tag: krb5-1.7-alpha1~578 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=c618db64af29b04b651cc8f354eec4ef7cbc5298;p=krb5.git 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: 5080 tags: pullup git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@20551 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/krb5/ccache/ccdefault.c b/src/lib/krb5/ccache/ccdefault.c index b7a592f74..c44a4771d 100644 --- a/src/lib/krb5/ccache/ccdefault.c +++ b/src/lib/krb5/ccache/ccdefault.c @@ -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); } }