From: Jeffrey Altman Date: Sun, 13 Nov 2011 17:06:18 +0000 (-0500) Subject: Windows: netidmgr krb5_cc_get_principal can fail X-Git-Tag: upstream/1.8.0_pre1^2~3042 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=e55d1774b1b5b27a3617467b5e2a24ee2be3a38c;p=packages%2Fo%2Fopenafs.git Windows: netidmgr krb5_cc_get_principal can fail Do not dereference a NULL pointer if krb5_cc_get_principal fails. Change-Id: Ic213f0c41249931441bcedaf551acaa160ff7f0f Reviewed-on: http://gerrit.openafs.org/6016 Tested-by: BuildBot Reviewed-by: Jeffrey Altman Tested-by: Jeffrey Altman --- diff --git a/src/WINNT/netidmgr_plugin/afsfuncs.c b/src/WINNT/netidmgr_plugin/afsfuncs.c index 93a83c431..3da709f94 100644 --- a/src/WINNT/netidmgr_plugin/afsfuncs.c +++ b/src/WINNT/netidmgr_plugin/afsfuncs.c @@ -852,9 +852,18 @@ afs_klog(khm_handle identity, memset(&increds, 0, sizeof(increds)); - krb5_cc_get_principal(context, k5cc, &client_principal); - StringCchCopyA(realm_of_user, ARRAYLENGTH(realm_of_user), - krb5_principal_get_realm(context, client_principal)); + r = krb5_cc_get_principal(context, k5cc, &client_principal); + if (!r) { + StringCchCopyA(realm_of_user, ARRAYLENGTH(realm_of_user), + krb5_principal_get_realm(context, client_principal)); + } else { + _reportf(L"krb5_cc_get_principal returns code %d", r); +#ifdef USE_KRB4 + goto try_krb4; +#else + goto end_krb5; +#endif + } } else { _reportf(L"khm_krb5_initialize returns code %d", r); #ifdef USE_KRB4