From 513edbb8b0956d316e547d81060e0cc023c4a4d3 Mon Sep 17 00:00:00 2001 From: Hartmut Brandt Date: Thu, 14 Jun 2007 19:58:24 +0000 Subject: [PATCH] According to the documentation mech_type for gss_init_sec_context() may be passed as GSS_C_NO_OID in which case a default mech should be used. This case was not handled and leads to core dumps when using nss_ldap. Now use the first mech in this case. When there is no mechanism available return an error (this part is taken from the PR). PR: 113266 Submitted by: Eirik Nygaard (partly) --- lib/libgssapi/gss_init_sec_context.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/libgssapi/gss_init_sec_context.c b/lib/libgssapi/gss_init_sec_context.c index 0d4099eca98e..b9325fe94ee7 100644 --- a/lib/libgssapi/gss_init_sec_context.c +++ b/lib/libgssapi/gss_init_sec_context.c @@ -41,7 +41,7 @@ gss_init_sec_context(OM_uint32 * minor_status, const gss_cred_id_t initiator_cred_handle, gss_ctx_id_t * context_handle, const gss_name_t target_name, - const gss_OID mech_type, + const gss_OID imech_type, OM_uint32 req_flags, OM_uint32 time_req, const gss_channel_bindings_t input_chan_bindings, @@ -52,6 +52,7 @@ gss_init_sec_context(OM_uint32 * minor_status, OM_uint32 * time_rec) { OM_uint32 major_status; + gss_OID mech_type; struct _gss_mech_switch *m; struct _gss_name *name = (struct _gss_name *) target_name; struct _gss_mechanism_name *mn; @@ -63,6 +64,13 @@ gss_init_sec_context(OM_uint32 * minor_status, *minor_status = 0; + if ((mech_type = imech_type) == GSS_C_NO_OID) { + _gss_load_mech(); + mech_type = &SLIST_FIRST(&_gss_mechs)->gm_mech_oid; + if (mech_type == NULL) + return (GSS_S_BAD_MECH); + } + /* * If we haven't allocated a context yet, do so now and lookup * the mechanism switch table. If we have one already, make