X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=wrap.c;h=122945e11875f89a9b56a1e8b7eaa44ae0b24381;hb=15c93f06ee6ddefa7e7b095351f6e66698c7cc9e;hp=90e2059dafd86d2ab1252538455e6d6c59cb729b;hpb=d5a9b52e3911edd09988005462028ed7dbdf5899;p=mech_eap.git diff --git a/wrap.c b/wrap.c index 90e2059..122945e 100644 --- a/wrap.c +++ b/wrap.c @@ -41,21 +41,30 @@ gss_wrap(OM_uint32 *minor, int *conf_state, gss_buffer_t output_message_buffer) { - OM_uint32 major = GSS_C_NO_CONTEXT; + OM_uint32 major; - *minor = 0; - - if (ctx == GSS_C_NO_CONTEXT) + if (ctx == GSS_C_NO_CONTEXT) { + *minor = EINVAL; return GSS_S_NO_CONTEXT; + } + + *minor = 0; GSSEAP_MUTEX_LOCK(&ctx->mutex); - if (CTX_IS_ESTABLISHED(ctx)) { - major = gssEapWrap(minor, ctx, conf_req_flag, qop_req, - input_message_buffer, - conf_state, output_message_buffer); + if (!CTX_IS_ESTABLISHED(ctx)) { + *minor = GSSEAP_CONTEXT_INCOMPLETE; + major = GSS_S_NO_CONTEXT; + goto cleanup; } + major = gssEapWrap(minor, ctx, conf_req_flag, qop_req, + input_message_buffer, + conf_state, output_message_buffer); + if (GSS_ERROR(major)) + goto cleanup; + +cleanup: GSSEAP_MUTEX_UNLOCK(&ctx->mutex); return major;