35
35
#include <string.h>
39
OM_uint32 *minor_status,
40
gss_buffer_t interprocess_token,
41
gss_ctx_id_t *context_handle)
44
/* Initialize outputs. */
45
if (minor_status != NULL)
48
if (context_handle != NULL)
49
*context_handle = GSS_C_NO_CONTEXT;
51
/* Validate arguments. */
53
if (minor_status == NULL)
54
return (GSS_S_CALL_INACCESSIBLE_WRITE);
56
if (context_handle == NULL)
57
return (GSS_S_CALL_INACCESSIBLE_WRITE);
59
if (interprocess_token == GSS_C_NO_BUFFER)
60
return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_DEFECTIVE_TOKEN);
62
if (GSS_EMPTY_BUFFER(interprocess_token))
63
return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_DEFECTIVE_TOKEN);
65
return (GSS_S_COMPLETE);
37
69
OM_uint32 KRB5_CALLCONV
38
70
gss_import_sec_context(minor_status,
39
71
interprocess_token,
44
76
gss_ctx_id_t * context_handle;
50
82
gss_union_ctx_id_t ctx;
51
83
gss_buffer_desc token;
52
84
gss_mechanism mech;
58
if (interprocess_token->length == 0 || interprocess_token->value == 0)
59
return (GSS_S_DEFECTIVE_TOKEN);
86
status = val_imp_sec_ctx_args(minor_status,
87
interprocess_token, context_handle);
88
if (status != GSS_S_COMPLETE)
91
/* Initial value needed below. */
61
92
status = GSS_S_FAILURE;
63
94
ctx = (gss_union_ctx_id_t) malloc(sizeof(gss_union_ctx_id_desc));
65
*minor_status = ENOMEM;
96
return (GSS_S_FAILURE);
68
98
ctx->mech_type = (gss_OID) malloc(sizeof(gss_OID_desc));
69
99
if (!ctx->mech_type) {
70
*minor_status = ENOMEM;
73
p = interprocess_token->value;
75
length = (length << 8) + *p++;
76
length = (length << 8) + *p++;
77
length = (length << 8) + *p++;
101
return (GSS_S_FAILURE);
104
if (interprocess_token->length >= sizeof (OM_uint32)) {
105
p = interprocess_token->value;
106
length = (OM_uint32)*p++;
107
length = (OM_uint32)(length << 8) + *p++;
108
length = (OM_uint32)(length << 8) + *p++;
109
length = (OM_uint32)(length << 8) + *p++;
113
length > (interprocess_token->length - sizeof (OM_uint32))) {
115
return (GSS_S_CALL_BAD_STRUCTURE | GSS_S_DEFECTIVE_TOKEN);
79
118
ctx->mech_type->length = length;
80
119
ctx->mech_type->elements = malloc(length);
81
120
if (!ctx->mech_type->elements) {
82
*minor_status = ENOMEM;
85
123
memcpy(ctx->mech_type->elements, p, length);
88
token.length = interprocess_token->length - 4 - length;
126
token.length = interprocess_token->length - sizeof (OM_uint32) - length;
96
mech = __gss_get_mechanism (ctx->mech_type);
134
mech = gssint_get_mechanism (ctx->mech_type);
98
136
status = GSS_S_BAD_MECH;
101
139
if (!mech->gss_import_sec_context) {
102
status = GSS_S_BAD_BINDINGS;
140
status = GSS_S_UNAVAILABLE;