/* Now create a new context if we didn't get one. */
if (*context_handle == GSS_C_NO_CONTEXT) {
- status = GSS_S_FAILURE;
- union_ctx_id = (gss_union_ctx_id_t)
- malloc(sizeof(gss_union_ctx_id_desc));
- if (!union_ctx_id)
- return (GSS_S_FAILURE);
-
- union_ctx_id->loopback = union_ctx_id;
- union_ctx_id->internal_ctx_id = GSS_C_NO_CONTEXT;
- status = generic_gss_copy_oid(&temp_minor_status, selected_mech,
- &union_ctx_id->mech_type);
- if (status != GSS_S_COMPLETE) {
- free(union_ctx_id);
+ status = gssint_create_union_context(minor_status, selected_mech,
+ &union_ctx_id);
+ if (status != GSS_S_COMPLETE)
return (status);
- }
}
/*
return (GSS_S_COMPLETE);
} /* ****** gssint_create_copy_buffer ****** */
+
+OM_uint32
+gssint_create_union_context(OM_uint32 *minor, gss_const_OID mech_oid,
+ gss_union_ctx_id_t *ctx_out)
+{
+ OM_uint32 status;
+ gss_union_ctx_id_t ctx;
+
+ *ctx_out = NULL;
+
+ ctx = calloc(1, sizeof(*ctx));
+ if (ctx == NULL) {
+ *minor = ENOMEM;
+ return GSS_S_FAILURE;
+ }
+
+ status = generic_gss_copy_oid(minor, mech_oid, &ctx->mech_type);
+ if (status != GSS_S_COMPLETE) {
+ free(ctx);
+ return status;
+ }
+
+ ctx->loopback = ctx;
+ ctx->internal_ctx_id = GSS_C_NO_CONTEXT;
+
+ *ctx_out = ctx;
+ return GSS_S_COMPLETE;
+}
/* Initial value needed below. */
status = GSS_S_FAILURE;
- ctx = (gss_union_ctx_id_t) malloc(sizeof(gss_union_ctx_id_desc));
- if (!ctx)
- return (GSS_S_FAILURE);
-
if (interprocess_token->length >= sizeof (OM_uint32)) {
p = interprocess_token->value;
length = (OM_uint32)*p++;
if (length == 0 ||
length > (interprocess_token->length - sizeof (OM_uint32))) {
- free(ctx);
return (GSS_S_CALL_BAD_STRUCTURE | GSS_S_DEFECTIVE_TOKEN);
}
status = gssint_select_mech_type(minor_status, &token_mech,
&selected_mech);
if (status != GSS_S_COMPLETE)
- goto error_out;
+ return status;
mech = gssint_get_mechanism(selected_mech);
- if (!mech) {
- status = GSS_S_BAD_MECH;
- goto error_out;
- }
+ if (!mech)
+ return GSS_S_BAD_MECH;
if (!mech->gssspi_import_sec_context_by_mech &&
- !mech->gss_import_sec_context) {
- status = GSS_S_UNAVAILABLE;
- goto error_out;
- }
+ !mech->gss_import_sec_context)
+ return GSS_S_UNAVAILABLE;
- if (generic_gss_copy_oid(minor_status, selected_mech,
- &ctx->mech_type) != GSS_S_COMPLETE) {
- status = GSS_S_FAILURE;
- goto error_out;
- }
+ status = gssint_create_union_context(minor_status, selected_mech, &ctx);
+ if (status != GSS_S_COMPLETE)
+ return status;
if (mech->gssspi_import_sec_context_by_mech) {
public_mech = gssint_get_public_oid(selected_mech);
}
if (status == GSS_S_COMPLETE) {
ctx->internal_ctx_id = mctx;
- ctx->loopback = ctx;
*context_handle = (gss_ctx_id_t)ctx;
return (GSS_S_COMPLETE);
}
map_error(minor_status, mech);
free(ctx->mech_type->elements);
free(ctx->mech_type);
-
-error_out:
free(ctx);
return status;
}
*/
if(*context_handle == GSS_C_NO_CONTEXT) {
- status = GSS_S_FAILURE;
- union_ctx_id = (gss_union_ctx_id_t)
- malloc(sizeof(gss_union_ctx_id_desc));
- if (union_ctx_id == NULL)
+ status = gssint_create_union_context(minor_status, selected_mech,
+ &union_ctx_id);
+ if (status != GSS_S_COMPLETE)
goto end;
-
- if (generic_gss_copy_oid(&temp_minor_status, selected_mech,
- &union_ctx_id->mech_type) != GSS_S_COMPLETE) {
- free(union_ctx_id);
- goto end;
- }
-
- /* copy the supplied context handle */
- union_ctx_id->internal_ctx_id = GSS_C_NO_CONTEXT;
} else {
union_ctx_id = (gss_union_ctx_id_t)*context_handle;
if (union_ctx_id->internal_ctx_id == GSS_C_NO_CONTEXT) {
free(union_ctx_id);
}
} else if (*context_handle == GSS_C_NO_CONTEXT) {
- union_ctx_id->loopback = union_ctx_id;
*context_handle = (gss_ctx_id_t)union_ctx_id;
}
&internal_ctx,
desired_object,
value);
- if (status == GSS_S_COMPLETE) {
- if (ctx == NULL && internal_ctx != GSS_C_NO_CONTEXT) {
- /* Allocate a union context handle to wrap new context */
- ctx = (gss_union_ctx_id_t)malloc(sizeof(*ctx));
- if (ctx == NULL) {
- *minor_status = ENOMEM;
- gssint_delete_internal_sec_context(&minor,
- &mech->mech_type,
- &internal_ctx,
- GSS_C_NO_BUFFER);
- return GSS_S_FAILURE;
- }
-
- status = generic_gss_copy_oid(minor_status,
- &mech->mech_type,
- &ctx->mech_type);
- if (status != GSS_S_COMPLETE) {
- gssint_delete_internal_sec_context(&minor,
- ctx->mech_type,
- &internal_ctx,
- GSS_C_NO_BUFFER);
- free(ctx);
- return status;
- }
+ if (status != GSS_S_COMPLETE) {
+ map_error(minor_status, mech);
+ return status;
+ }
- ctx->loopback = ctx;
- ctx->internal_ctx_id = internal_ctx;
- *context_handle = (gss_ctx_id_t)ctx;
+ if (ctx == NULL && internal_ctx != GSS_C_NO_CONTEXT) {
+ status = gssint_create_union_context(minor_status, &mech->mech_type,
+ &ctx);
+ if (status != GSS_S_COMPLETE) {
+ gssint_delete_internal_sec_context(&minor, ctx->mech_type,
+ &internal_ctx, GSS_C_NO_BUFFER);
+ return status;
}
- } else
- map_error(minor_status, mech);
- return status;
+ ctx->internal_ctx_id = internal_ctx;
+ *context_handle = (gss_ctx_id_t)ctx;
+ }
+
+ return GSS_S_COMPLETE;
}
int /* NULL terminate buffer ? */
);
+OM_uint32 gssint_create_union_context(
+ OM_uint32 *minor, /* minor_status */
+ gss_const_OID, /* mech_oid */
+ gss_union_ctx_id_t * /* ctx_out */
+);
+
OM_uint32 gssint_copy_oid_set(
OM_uint32 *, /* minor_status */
const gss_OID_set_desc * const, /* oid set */