When processing error tokens at the initiator, verify minor status
[mech_eap.orig] / util_context.c
index 9c6916d..9fa64c8 100644 (file)
  * SUCH DAMAGE.
  */
 
+/*
+ * Utility routines for context handles.
+ */
+
 #include "gssapiP_eap.h"
 
 OM_uint32
@@ -53,7 +57,7 @@ gssEapAllocContext(OM_uint32 *minor,
         return GSS_S_FAILURE;
     }
 
-    ctx->state = EAP_STATE_IDENTITY;
+    ctx->state = GSSEAP_STATE_IDENTITY;
 
     /*
      * Integrity, confidentiality, sequencing and replay detection are
@@ -87,12 +91,15 @@ releaseAcceptorContext(struct gss_eap_acceptor_ctx *ctx)
 {
     OM_uint32 tmpMinor;
 
-    if (ctx->avps != NULL)
-        rc_avpair_free(ctx->avps);
-    if (ctx->radHandle != NULL)
-        rc_config_free(ctx->radHandle);
-
+    if (ctx->radConn != NULL)
+        rs_conn_destroy(ctx->radConn);
+    if (ctx->radContext != NULL)
+        rs_context_destroy(ctx->radContext);
+    if (ctx->radServer != NULL)
+        GSSEAP_FREE(ctx->radServer);
     gss_release_buffer(&tmpMinor, &ctx->state);
+    if (ctx->vps != NULL)
+        gssEapRadiusFreeAvps(&tmpMinor, &ctx->vps);
 }
 
 OM_uint32
@@ -110,7 +117,7 @@ gssEapReleaseContext(OM_uint32 *minor,
     gssEapKerberosInit(&tmpMinor, &krbContext);
 
 #ifdef GSSEAP_ENABLE_REAUTH
-    if (ctx->flags & CTX_FLAG_KRB_REAUTH_GSS) {
+    if (ctx->flags & CTX_FLAG_KRB_REAUTH) {
         gssDeleteSecContext(&tmpMinor, &ctx->kerberosCtx, GSS_C_NO_BUFFER);
     } else
 #endif
@@ -187,8 +194,10 @@ gssEapVerifyToken(OM_uint32 *minor,
         return major;
 
     if (ctx->mechanismUsed == GSS_C_NO_OID) {
-        if (!gssEapIsConcreteMechanismOid(oid))
+        if (!gssEapIsConcreteMechanismOid(oid)) {
+            *minor = GSSEAP_WRONG_MECH;
             return GSS_S_BAD_MECH;
+        }
 
         if (!gssEapInternalizeOid(oid, &ctx->mechanismUsed)) {
             major = duplicateOid(minor, oid, &ctx->mechanismUsed);