1   /*
   2    * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
   3    * Use is subject to license terms.
   4    */
   5   
   6 | #pragma ident        "@(#)g_rel_cred.c        1.15        04/09/08 SMI"
   6 | #pragma ident        "@(#)g_rel_cred.c        1.14        04/02/23 SMI"
   7   
   8   /*
   9    *  glue routine for gss_release_cred
  10    */
  11   
  12   #include <mechglueP.h>
  13   #include <stdio.h>
  14   #ifdef HAVE_STDLIB_H
  15   #include <stdlib.h>
  16   #endif
  17   
  18   OM_uint32
  19   gss_release_cred(minor_status,
  20                           cred_handle)
  21   
  22   OM_uint32                 *minor_status;
  23   gss_cred_id_t                 *cred_handle;
  24   
  25   {
  26           OM_uint32                status, temp_status;
  27           int                        j;
  28           gss_union_cred_t        union_cred;
  29           gss_mechanism                mech;
  30   
  31 |         gss_initialize();
  31 |         if (minor_status == NULL)
  32 +                 return (GSS_S_CALL_INACCESSIBLE_WRITE);
  33 -         if (minor_status)
  33   
  34           *minor_status = 0;
  35   
  36 |         /* if the cred_handle is null, return a NO_CRED error */
  36 |         if (cred_handle == NULL)
  37 +                 return (GSS_S_NO_CRED | GSS_S_CALL_INACCESSIBLE_READ);
  38 -         if (cred_handle == GSS_C_NO_CREDENTIAL)
  39 -                 return (GSS_S_NO_CRED);
  40 - 
  38   
  39           /*
  40            * Loop through the union_cred struct, selecting the approprate
  41            * underlying mechanism routine and calling it. At the end,
  42            * release all of the storage taken by the union_cred struct.
  43            */
  44   
  45           union_cred = (gss_union_cred_t)*cred_handle;
  46           *cred_handle = NULL;
  47   
  50 |         if (union_cred == NULL)
  51 |                 return (GSS_S_NO_CRED);
  48 |         if (union_cred == (gss_union_cred_t)GSS_C_NO_CREDENTIAL)
  49 |                 return (GSS_S_COMPLETE);
  50   
  51           status = GSS_S_COMPLETE;
  52   
  53           for (j = 0; j < union_cred->count; j++) {
  54   
  55                   mech = __gss_get_mechanism(&union_cred->mechs_array[j]);
  56   
  57                   if (union_cred->mechs_array[j].elements)
  58                           free(union_cred->mechs_array[j].elements);
  59                   if (mech) {
  60                           if (mech->gss_release_cred) {
  61                                   temp_status = mech->gss_release_cred
  62                                                   (mech->context, minor_status,
  63                                                   &union_cred->cred_array[j]);
  64   
  65                                   if (temp_status != GSS_S_COMPLETE)
  66                                           status = GSS_S_NO_CRED;
  67                           } else
  70 |                                 status = GSS_S_NO_CRED;
  68 |                                 status = GSS_S_UNAVAILABLE;
  69                   } else
  72 |                         status = GSS_S_NO_CRED;
  70 |                         status = GSS_S_DEFECTIVE_CREDENTIAL;
  71           }
  72   
  73           (void) gss_release_buffer(minor_status, &union_cred->auxinfo.name);
  74           free(union_cred->cred_array);
  75           free(union_cred->mechs_array);
  76           free(union_cred);
  77   
  78           return (status);
  79   }

 ----Unchanged portion omitted----