8030 libmvect: uninitialized variable
[unleashed.git] / usr / src / lib / libgss / g_inquire_context.c
bloba2188c94ed97e4f28b5d39a9ec3a1503a45f81dd
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
22 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
26 * glue routine for gss_inquire_context
29 #include <mechglueP.h>
30 #include "gssapiP_generic.h"
31 #include <stdlib.h>
33 static OM_uint32
34 val_inq_ctx_args(
35 OM_uint32 *minor_status,
36 gss_ctx_id_t context_handle,
37 gss_name_t *src_name,
38 gss_name_t *targ_name,
39 gss_OID *mech_type)
42 /* Initialize outputs. */
44 if (minor_status != NULL)
45 *minor_status = 0;
47 if (src_name != NULL)
48 *src_name = GSS_C_NO_NAME;
50 if (targ_name != NULL)
51 *targ_name = GSS_C_NO_NAME;
53 if (mech_type != NULL)
54 *mech_type = GSS_C_NO_OID;
56 /* Validate arguments. */
58 if (minor_status == NULL)
59 return (GSS_S_CALL_INACCESSIBLE_WRITE);
61 if (context_handle == GSS_C_NO_CONTEXT)
62 return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_NO_CONTEXT);
64 return (GSS_S_COMPLETE);
67 /* Last argument new for V2 */
68 OM_uint32
69 gss_inquire_context(
70 OM_uint32 *minor_status,
71 gss_ctx_id_t context_handle,
72 gss_name_t *src_name,
73 gss_name_t *targ_name,
74 OM_uint32 *lifetime_rec,
75 gss_OID *mech_type,
76 OM_uint32 *ctx_flags,
77 int *locally_initiated,
78 int *opened)
80 gss_union_ctx_id_t ctx;
81 gss_mechanism mech;
82 OM_uint32 status, temp_minor;
83 gss_name_t localTargName = NULL, localSourceName = NULL;
85 status = val_inq_ctx_args(minor_status,
86 context_handle,
87 src_name,
88 targ_name,
89 mech_type);
90 if (status != GSS_S_COMPLETE)
91 return (status);
94 * select the approprate underlying mechanism routine and
95 * call it.
98 ctx = (gss_union_ctx_id_t)context_handle;
99 mech = __gss_get_mechanism(ctx->mech_type);
101 if (!mech || !mech->gss_inquire_context || !mech->gss_display_name ||
102 !mech->gss_release_name) {
103 return (GSS_S_UNAVAILABLE);
106 status = mech->gss_inquire_context(
107 mech->context,
108 minor_status,
109 ctx->internal_ctx_id,
110 (src_name ? &localSourceName : NULL),
111 (targ_name ? &localTargName : NULL),
112 lifetime_rec,
113 NULL,
114 ctx_flags,
115 locally_initiated,
116 opened);
118 if (status != GSS_S_COMPLETE) {
119 map_error(minor_status, mech);
120 return (status);
123 /* need to convert names */
124 if (src_name) {
125 status = __gss_convert_name_to_union_name(minor_status, mech,
126 localSourceName, src_name);
127 if (status != GSS_S_COMPLETE) {
128 if (localTargName)
129 mech->gss_release_name(mech->context,
130 &temp_minor, &localTargName);
131 return (status);
135 if (targ_name) {
136 status = __gss_convert_name_to_union_name(minor_status, mech,
137 localTargName, targ_name);
139 if (status != GSS_S_COMPLETE) {
140 if (src_name)
141 (void) gss_release_name(&temp_minor, src_name);
143 return (status);
147 /* spec says mech type must point to static storage */
148 if (mech_type)
149 *mech_type = &mech->mech_type;
150 return (GSS_S_COMPLETE);