LCOV - code coverage report
Current view: top level - third_party/heimdal/lib/gssapi/mech - gssspi_query_meta_data.c (source / functions) Hit Total Coverage
Test: coverage report for master 2f515e9b Lines: 0 50 0.0 %
Date: 2024-04-21 15:09:00 Functions: 0 1 0.0 %

          Line data    Source code
       1             : /*-
       2             :  * Copyright (c) 2005 Doug Rabson
       3             :  * All rights reserved.
       4             :  *
       5             :  * Portions Copyright (c) 2009 Apple Inc. All rights reserved.
       6             :  * Portions Copyright (c) 2019 AuriStor, Inc. All rights reserved.
       7             :  *
       8             :  * Redistribution and use in source and binary forms, with or without
       9             :  * modification, are permitted provided that the following conditions
      10             :  * are met:
      11             :  * 1. Redistributions of source code must retain the above copyright
      12             :  *    notice, this list of conditions and the following disclaimer.
      13             :  * 2. Redistributions in binary form must reproduce the above copyright
      14             :  *    notice, this list of conditions and the following disclaimer in the
      15             :  *    documentation and/or other materials provided with the distribution.
      16             :  *
      17             :  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
      18             :  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
      19             :  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
      20             :  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
      21             :  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
      22             :  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
      23             :  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
      24             :  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
      25             :  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
      26             :  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
      27             :  * SUCH DAMAGE.
      28             :  */
      29             : 
      30             : #include "mech_locl.h"
      31             : 
      32             : GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
      33           0 : gssspi_query_meta_data(
      34             :     OM_uint32 *minor_status,
      35             :     gss_const_OID input_mech_type,
      36             :     gss_cred_id_t input_cred_handle,
      37             :     gss_ctx_id_t *context_handle,
      38             :     gss_const_name_t target_name,
      39             :     OM_uint32 req_flags,
      40             :     gss_buffer_t meta_data)
      41             : {
      42           0 :     OM_uint32 major_status, junk;
      43           0 :     gssapi_mech_interface m;
      44           0 :     struct _gss_name *name = (struct _gss_name *) target_name;
      45           0 :     struct _gss_mechanism_name *mn;
      46           0 :     struct _gss_context *ctx = (struct _gss_context *) *context_handle;
      47           0 :     gss_cred_id_t cred_handle;
      48           0 :     int allocated_ctx;
      49           0 :     gss_const_OID mech_type = input_mech_type;
      50             : 
      51           0 :     *minor_status = 0;
      52             : 
      53           0 :     _mg_buffer_zero(meta_data);
      54             : 
      55           0 :     if (mech_type == GSS_C_NO_OID)
      56           0 :         return GSS_S_BAD_MECH;
      57             : 
      58           0 :     if (ctx == NULL) {
      59           0 :         ctx = calloc(1, sizeof(struct _gss_context));
      60           0 :         if (ctx == NULL) {
      61           0 :             *minor_status = ENOMEM;
      62           0 :             return GSS_S_FAILURE;
      63             :         }
      64             : 
      65           0 :         m = ctx->gc_mech = __gss_get_mechanism(mech_type);
      66           0 :         if (m == NULL) {
      67           0 :             free(ctx);
      68           0 :             return GSS_S_BAD_MECH;
      69             :         }
      70           0 :         allocated_ctx = 1;
      71             :     } else {
      72           0 :         m = ctx->gc_mech;
      73           0 :         mech_type = &m->gm_mech_oid;
      74           0 :         allocated_ctx = 0;
      75             :     }
      76             : 
      77           0 :     if (m->gm_query_meta_data == NULL) {
      78           0 :         major_status = GSS_S_BAD_MECH;
      79           0 :         goto cleanup;
      80             :     }
      81             : 
      82           0 :     major_status = _gss_find_mn(minor_status, name, mech_type, &mn);
      83           0 :     if (major_status != GSS_S_COMPLETE)
      84           0 :         goto cleanup;
      85             : 
      86           0 :     if (m->gm_flags & GM_USE_MG_CRED)
      87           0 :         cred_handle = input_cred_handle;
      88             :     else
      89           0 :         cred_handle = _gss_mg_find_mech_cred(input_cred_handle, mech_type);
      90             : 
      91           0 :     if (input_cred_handle != GSS_C_NO_CREDENTIAL &&
      92           0 :         cred_handle == NULL) {
      93           0 :         major_status = GSS_S_NO_CRED;
      94           0 :         goto cleanup;
      95             :     }
      96             : 
      97             :     /* note: mechanism is not obligated to allocate a context on success */
      98           0 :     major_status = m->gm_query_meta_data(minor_status,
      99             :             mech_type,
     100             :             cred_handle,
     101           0 :             &ctx->gc_ctx,
     102           0 :             mn ? mn->gmn_name : GSS_C_NO_NAME,
     103             :             req_flags,
     104             :             meta_data);
     105           0 :     if (major_status != GSS_S_COMPLETE)
     106           0 :         _gss_mg_error(m, *minor_status);
     107             : 
     108           0 : cleanup:
     109           0 :     if (allocated_ctx && major_status != GSS_S_COMPLETE)
     110           0 :         gss_delete_sec_context(&junk, (gss_ctx_id_t *)&ctx, GSS_C_NO_BUFFER);
     111             : 
     112           0 :     *context_handle = (gss_ctx_id_t) ctx;
     113             : 
     114           0 :     _gss_mg_log(10, "gss-qmd: return %d/%d", (int)major_status, (int)*minor_status);
     115             : 
     116           0 :     return major_status;
     117             : }

Generated by: LCOV version 1.14