Path: blob/main/crypto/krb5/src/lib/gssapi/mechglue/g_rel_name.c
39586 views
/* #pragma ident "@(#)g_rel_name.c 1.11 04/02/23 SMI" */12/*3* Copyright 1996 by Sun Microsystems, Inc.4*5* Permission to use, copy, modify, distribute, and sell this software6* and its documentation for any purpose is hereby granted without fee,7* provided that the above copyright notice appears in all copies and8* that both that copyright notice and this permission notice appear in9* supporting documentation, and that the name of Sun Microsystems not be used10* in advertising or publicity pertaining to distribution of the software11* without specific, written prior permission. Sun Microsystems makes no12* representations about the suitability of this software for any13* purpose. It is provided "as is" without express or implied warranty.14*15* SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,16* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO17* EVENT SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR18* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF19* USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR20* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR21* PERFORMANCE OF THIS SOFTWARE.22*/2324/*25* glue routine for gss_release_name26*/2728#include "mglueP.h"29#include <stdio.h>30#ifdef HAVE_STDLIB_H31#include <stdlib.h>32#endif33#include <string.h>3435OM_uint32 KRB5_CALLCONV36gss_release_name(OM_uint32 *minor_status, gss_name_t *input_name)37{38gss_union_name_t union_name;3940if (minor_status == NULL)41return (GSS_S_CALL_INACCESSIBLE_WRITE);42*minor_status = 0;4344/* if input_name is NULL, return error */45if (input_name == NULL)46return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_BAD_NAME);4748if (*input_name == GSS_C_NO_NAME)49return GSS_S_COMPLETE;5051/*52* free up the space for the external_name and then53* free the union_name descriptor54*/5556union_name = (gss_union_name_t) *input_name;57if (GSSINT_CHK_LOOP(union_name))58return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_BAD_NAME);59*input_name = 0;60*minor_status = 0;6162if (union_name->name_type != GSS_C_NO_OID)63gss_release_oid(minor_status, &union_name->name_type);6465if (union_name->external_name != GSS_C_NO_BUFFER) {66if (union_name->external_name->value != NULL)67gssalloc_free(union_name->external_name->value);68free(union_name->external_name);69}7071if (union_name->mech_type) {72gssint_release_internal_name(minor_status, union_name->mech_type,73&union_name->mech_name);74gss_release_oid(minor_status, &union_name->mech_type);75}7677free(union_name);7879return(GSS_S_COMPLETE);80}818283