-: 0:Source:g_dup_name.c -: 0:Graph:/var/tsitkova/Sources/v10/trunk/src/lib/gssapi/mechglue/g_dup_name.so.gcno -: 0:Data:/var/tsitkova/Sources/v10/trunk/src/lib/gssapi/mechglue/g_dup_name.so.gcda -: 0:Runs:1069 -: 0:Programs:1 -: 1:/* -: 2: * Copyright 2004 Sun Microsystems, Inc. All rights reserved. -: 3: * Use is subject to license terms. -: 4: */ -: 5: -: 6:/* #pragma ident "@(#)g_dup_name.c 1.14 04/02/23 SMI" */ -: 7: -: 8:/* -: 9: * routine gss_duplicate_name -: 10: * -: 11: * This routine does not rely on mechanism implementation of this -: 12: * name, but instead uses mechanism specific gss_import_name routine. -: 13: */ -: 14: -: 15:#include -: 16:#ifdef HAVE_STDLIB_H -: 17:#include -: 18:#endif -: 19:#include -: 20:#include -: 21: -: 22:static OM_uint32 6: 23:val_dup_name_args( -: 24: OM_uint32 *minor_status, -: 25: const gss_name_t src_name, -: 26: gss_name_t *dest_name) -: 27:{ -: 28: -: 29: /* Initialize outputs. */ -: 30: 6: 31: if (minor_status != NULL) 6: 32: *minor_status = 0; -: 33: 6: 34: if (dest_name != NULL) 6: 35: *dest_name = GSS_C_NO_NAME; -: 36: -: 37: /* Validate arguments. */ -: 38: 6: 39: if (minor_status == NULL) #####: 40: return (GSS_S_CALL_INACCESSIBLE_WRITE); -: 41: -: 42: /* if output_name is NULL, simply return */ 6: 43: if (dest_name == NULL) #####: 44: return (GSS_S_CALL_INACCESSIBLE_WRITE); -: 45: 6: 46: if (src_name == GSS_C_NO_NAME) #####: 47: return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_BAD_NAME); -: 48: 6: 49: return (GSS_S_COMPLETE); -: 50:} -: 51: -: 52: -: 53:OM_uint32 KRB5_CALLCONV 6: 54:gss_duplicate_name(minor_status, -: 55: src_name, -: 56: dest_name) -: 57:OM_uint32 *minor_status; -: 58:const gss_name_t src_name; -: 59:gss_name_t *dest_name; -: 60:{ -: 61: gss_union_name_t src_union, dest_union; 6: 62: OM_uint32 major_status = GSS_S_FAILURE; -: 63: 6: 64: major_status = val_dup_name_args(minor_status, src_name, dest_name); 6: 65: if (major_status != GSS_S_COMPLETE) #####: 66: return (major_status); -: 67: 6: 68: src_union = (gss_union_name_t)src_name; -: 69: -: 70: /* -: 71: * First create the union name struct that will hold the external -: 72: * name and the name type. -: 73: */ 6: 74: dest_union = (gss_union_name_t)malloc(sizeof (gss_union_name_desc)); 6: 75: if (!dest_union) #####: 76: goto allocation_failure; -: 77: 6: 78: dest_union->loopback = 0; 6: 79: dest_union->mech_type = 0; 6: 80: dest_union->mech_name = 0; 6: 81: dest_union->name_type = 0; 6: 82: dest_union->external_name = 0; -: 83: -: 84: /* Now copy the external representaion */ 6: 85: if (gssint_create_copy_buffer(src_union->external_name, -: 86: &dest_union->external_name, 0)) #####: 87: goto allocation_failure; -: 88: 6: 89: if (src_union->name_type != GSS_C_NULL_OID) { 12: 90: major_status = generic_gss_copy_oid(minor_status, 6: 91: src_union->name_type, -: 92: &dest_union->name_type); 6: 93: if (major_status != GSS_S_COMPLETE) { #####: 94: map_errcode(minor_status); #####: 95: goto allocation_failure; -: 96: } -: 97: } -: 98: -: 99: /* -: 100: * See if source name is mechanim specific, if so then need to import it -: 101: */ 6: 102: if (src_union->mech_type) { #####: 103: major_status = generic_gss_copy_oid(minor_status, #####: 104: src_union->mech_type, -: 105: &dest_union->mech_type); #####: 106: if (major_status != GSS_S_COMPLETE) { #####: 107: map_errcode(minor_status); #####: 108: goto allocation_failure; -: 109: } -: 110: #####: 111: major_status = gssint_import_internal_name(minor_status, -: 112: src_union->mech_type, -: 113: src_union, -: 114: &dest_union->mech_name); #####: 115: if (major_status != GSS_S_COMPLETE) #####: 116: goto allocation_failure; -: 117: } -: 118: -: 119: 6: 120: dest_union->loopback = dest_union; 6: 121: *dest_name = (gss_name_t)dest_union; 6: 122: return (GSS_S_COMPLETE); -: 123: -: 124:allocation_failure: #####: 125: if (dest_union) { #####: 126: if (dest_union->external_name) { #####: 127: if (dest_union->external_name->value) #####: 128: free(dest_union->external_name->value); #####: 129: free(dest_union->external_name); -: 130: } #####: 131: if (dest_union->name_type) #####: 132: (void) generic_gss_release_oid(minor_status, -: 133: &dest_union->name_type); #####: 134: if (dest_union->mech_name) #####: 135: (void) gssint_release_internal_name(minor_status, -: 136: dest_union->mech_type, -: 137: &dest_union->mech_name); #####: 138: if (dest_union->mech_type) #####: 139: (void) generic_gss_release_oid(minor_status, -: 140: &dest_union->mech_type); #####: 141: free(dest_union); -: 142: } #####: 143: return (major_status); -: 144:} /* gss_duplicate_name */