Windows: netidmgr krb5_cc_get_principal can fail
authorJeffrey Altman <jaltman@your-file-system.com>
Sun, 13 Nov 2011 17:06:18 +0000 (12:06 -0500)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Mon, 14 Nov 2011 14:49:17 +0000 (06:49 -0800)
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 <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@secure-endpoints.com>
Tested-by: Jeffrey Altman <jaltman@secure-endpoints.com>

src/WINNT/netidmgr_plugin/afsfuncs.c

index 93a83c4..3da709f 100644 (file)
@@ -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