Udiff g_inquire_context.c
--- /net/etna.eng/build7/semery/mit2/webrev/usr/src/lib/libgss/g_inquire_context.c-     Wed Sep  8 17:00:30 2004
+++ g_inquire_context.c Wed Sep  8 13:42:03 2004
@@ -1,11 +1,11 @@
 /*
  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
-#pragma ident  "@(#)g_inquire_context.c        1.16    04/09/08 SMI"
+#pragma ident  "@(#)g_inquire_context.c        1.15    04/02/23 SMI"
 
 /*
  *  glue routine for gss_inquire_context
  */
 
@@ -37,38 +37,52 @@
 
 {
        gss_union_ctx_id_t      ctx;
        gss_mechanism           mech;
        OM_uint32               status, temp_minor;
+       gss_name_t localTargName = NULL, localSourceName = NULL;
 
-       gss_initialize();
+       if (!minor_status)
+               return (GSS_S_CALL_INACCESSIBLE_WRITE);
 
-       /* if the context_handle is Null, return NO_CONTEXT error */
+       *minor_status = 0;
 
+       /* if the context_handle is Null, return NO_CONTEXT error */
        if (context_handle == GSS_C_NO_CONTEXT)
-               return (GSS_S_NO_CONTEXT);
+               return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_NO_CONTEXT);
 
+       /* set all output value to NULL */
+       if (src_name)
+               *src_name = NULL;
+
+       if (targ_name)
+               *targ_name = NULL;
+
+       if (mech_type)
+               *mech_type = NULL;
+
        /*
         * select the approprate underlying mechanism routine and
         * call it.
         */
 
        ctx = (gss_union_ctx_id_t)context_handle;
        mech = __gss_get_mechanism(ctx->mech_type);
 
-       if (!mech || !mech->gss_inquire_context || !mech->gss_display_name) {
-               return (GSS_S_NO_CONTEXT);
+       if (!mech || !mech->gss_inquire_context || !mech->gss_display_name ||
+               !mech->gss_release_name) {
+               return (GSS_S_UNAVAILABLE);
        }
 
        status = mech->gss_inquire_context(
                                mech->context,
                                minor_status,
                                ctx->internal_ctx_id,
-                               src_name,
-                               targ_name,
+                               (src_name ? &localSourceName : NULL),
+                               (targ_name ? &localTargName : NULL),
                                lifetime_rec,
-                               mech_type,
+                               NULL,
                                ctx_flags,
                                locally_initiated,
                                open);
 
        if (status != GSS_S_COMPLETE) {
@@ -76,32 +90,31 @@
        }
 
        /* need to convert names */
        if (src_name) {
                status = __gss_convert_name_to_union_name(minor_status, mech,
-                                               *src_name, src_name);
+                                               localSourceName, src_name);
                if (status != GSS_S_COMPLETE) {
+                       if (localTargName)
                        mech->gss_release_name(mech->context,
-                                               &temp_minor, src_name);
-                       mech->gss_release_name(mech->context,
-                                               &temp_minor, targ_name);
-                       if (mech_type) {
-                               gss_release_oid(&temp_minor, mech_type);
+                                               &temp_minor, &localTargName);
+                       return (status);
                        }
-                       return (GSS_S_FAILURE);
                }
-       }
 
        if (targ_name) {
                status = __gss_convert_name_to_union_name(minor_status, mech,
-                                               *targ_name, targ_name);
+                                               localTargName, targ_name);
 
                if (status != GSS_S_COMPLETE) {
-                       if (mech_type)
-                               (void) gss_release_oid(&temp_minor, mech_type);
+                       if (src_name)
+                               (void) gss_release_name(&temp_minor, src_name);
 
-                       return (GSS_S_FAILURE);
+                       return (status);
                }
        }
 
+       /* spec says mech type must point to static storage */
+       if (mech_type)
+               *mech_type = &mech->mech_type;
        return (GSS_S_COMPLETE);
 }