allow pCtx to be NULL for Heimdal compat
authorLuke Howard <lukeh@padl.com>
Thu, 12 May 2011 21:24:45 +0000 (23:24 +0200)
committerLuke Howard <lukeh@padl.com>
Thu, 12 May 2011 21:25:02 +0000 (23:25 +0200)
moonshot/mech_eap/set_sec_context_option.c

index 1f373c2..45ef266 100644 (file)
@@ -50,12 +50,17 @@ gss_set_sec_context_option(OM_uint32 *minor,
                            const gss_buffer_t value)
 {
     OM_uint32 major;
-    gss_ctx_id_t ctx = *pCtx;
+    gss_ctx_id_t ctx;
     int i;
 
     major = GSS_S_UNAVAILABLE;
     *minor = GSSEAP_BAD_CONTEXT_OPTION;
 
+    if (pCtx == NULL)
+        ctx = GSS_C_NO_CONTEXT;
+    else
+        ctx = *pCtx;
+
     if (ctx != GSS_C_NO_CONTEXT)
         GSSEAP_MUTEX_LOCK(&ctx->mutex);
 
@@ -67,9 +72,9 @@ gss_set_sec_context_option(OM_uint32 *minor,
         }
     }
 
-    if (*pCtx == NULL)
+    if (pCtx != NULL && *pCtx == NULL)
         *pCtx = ctx;
-    else
+    else if (ctx != GSS_C_NO_CONTEXT)
         GSSEAP_MUTEX_UNLOCK(&ctx->mutex);
 
     return major;