From: Ezra Peisach Date: Tue, 9 May 2006 11:31:02 +0000 (+0000) Subject: Cleanup a number of cast away from const warnings in gssapi X-Git-Tag: krb5-1.5-alpha1~36 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=55813dc64944fa86b9da65ece7ab8cc6a1c6df74;p=krb5.git Cleanup a number of cast away from const warnings in gssapi Change internal token handling and oid handling functions to take a const style gss_OID. In the krb5 dir remove casting. This is the start of fixes in this arena. ticket: new git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@17987 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/gssapi/generic/gssapiP_generic.h b/src/lib/gssapi/generic/gssapiP_generic.h index 8936b63f0..ca19b1891 100644 --- a/src/lib/gssapi/generic/gssapiP_generic.h +++ b/src/lib/gssapi/generic/gssapiP_generic.h @@ -170,12 +170,13 @@ int g_make_string_buffer (const char *str, gss_buffer_t buffer); int g_copy_OID_set (const gss_OID_set_desc * const in, gss_OID_set *out); -unsigned int g_token_size (gss_OID mech, unsigned int body_size); +unsigned int g_token_size (const gss_OID_desc * mech, unsigned int body_size); -void g_make_token_header (gss_OID mech, unsigned int body_size, +void g_make_token_header (const gss_OID_desc * mech, unsigned int body_size, unsigned char **buf, int tok_type); -gss_int32 g_verify_token_header (gss_OID mech, unsigned int *body_size, +gss_int32 g_verify_token_header (const gss_OID_desc * mech, + unsigned int *body_size, unsigned char **buf, int tok_type, unsigned int toksize_in, int wrapper_required); @@ -223,7 +224,7 @@ OM_uint32 generic_gss_release_oid OM_uint32 generic_gss_copy_oid (OM_uint32 *, /* minor_status */ - gss_OID, /* oid */ + const gss_OID_desc * const, /* oid */ gss_OID * /* new_oid */ ); @@ -234,20 +235,20 @@ OM_uint32 generic_gss_create_empty_oid_set OM_uint32 generic_gss_add_oid_set_member (OM_uint32 *, /* minor_status */ - gss_OID, /* member_oid */ + const gss_OID_desc * const, /* member_oid */ gss_OID_set * /* oid_set */ ); OM_uint32 generic_gss_test_oid_set_member (OM_uint32 *, /* minor_status */ - gss_OID, /* member */ + const gss_OID_desc * const, /* member */ gss_OID_set, /* set */ int * /* present */ ); OM_uint32 generic_gss_oid_to_str (OM_uint32 *, /* minor_status */ - gss_OID, /* oid */ + const gss_OID_desc * const, /* oid */ gss_buffer_t /* oid_str */ ); diff --git a/src/lib/gssapi/generic/oid_ops.c b/src/lib/gssapi/generic/oid_ops.c index a73589879..1234f2ee7 100644 --- a/src/lib/gssapi/generic/oid_ops.c +++ b/src/lib/gssapi/generic/oid_ops.c @@ -75,7 +75,8 @@ generic_gss_release_oid(minor_status, oid) OM_uint32 generic_gss_copy_oid(minor_status, oid, new_oid) OM_uint32 *minor_status; - gss_OID oid, *new_oid; + const gss_OID_desc * const oid; + gss_OID *new_oid; { gss_OID p; @@ -116,7 +117,7 @@ generic_gss_create_empty_oid_set(minor_status, oid_set) OM_uint32 generic_gss_add_oid_set_member(minor_status, member_oid, oid_set) OM_uint32 *minor_status; - gss_OID member_oid; + const gss_OID_desc * const member_oid; gss_OID_set *oid_set; { gss_OID elist; @@ -161,7 +162,7 @@ generic_gss_add_oid_set_member(minor_status, member_oid, oid_set) OM_uint32 generic_gss_test_oid_set_member(minor_status, member, set, present) OM_uint32 *minor_status; - gss_OID member; + const gss_OID_desc * const member; gss_OID_set set; int *present; { @@ -189,7 +190,7 @@ generic_gss_test_oid_set_member(minor_status, member, set, present) OM_uint32 generic_gss_oid_to_str(minor_status, oid, oid_str) OM_uint32 *minor_status; - gss_OID oid; + const gss_OID_desc * const oid; gss_buffer_t oid_str; { char numstr[128]; diff --git a/src/lib/gssapi/generic/util_token.c b/src/lib/gssapi/generic/util_token.c index 6277e942a..7b8dfed22 100644 --- a/src/lib/gssapi/generic/util_token.c +++ b/src/lib/gssapi/generic/util_token.c @@ -133,7 +133,7 @@ static int der_read_length(buf, bufsize) /* returns the length of a token, given the mech oid and the body size */ unsigned int g_token_size(mech, body_size) - gss_OID mech; + const gss_OID_desc * mech; unsigned int body_size; { /* set body_size to sequence contents size */ @@ -145,7 +145,7 @@ unsigned int g_token_size(mech, body_size) be the right size. buf is advanced past the token header */ void g_make_token_header(mech, body_size, buf, tok_type) - gss_OID mech; + const gss_OID_desc * mech; unsigned int body_size; unsigned char **buf; int tok_type; @@ -172,7 +172,7 @@ void g_make_token_header(mech, body_size, buf, tok_type) gss_int32 g_verify_token_header(mech, body_size, buf_in, tok_type, toksize_in, wrapper_required) - gss_OID mech; + const gss_OID_desc * mech; unsigned int *body_size; unsigned char **buf_in; int tok_type; diff --git a/src/lib/gssapi/krb5/accept_sec_context.c b/src/lib/gssapi/krb5/accept_sec_context.c index 219d9da06..657176b86 100644 --- a/src/lib/gssapi/krb5/accept_sec_context.c +++ b/src/lib/gssapi/krb5/accept_sec_context.c @@ -336,13 +336,13 @@ krb5_gss_accept_sec_context(minor_status, context_handle, ptr = (unsigned char *) input_token->value; - if (!(code = g_verify_token_header((gss_OID) gss_mech_krb5, + if (!(code = g_verify_token_header(gss_mech_krb5, &(ap_req.length), &ptr, KG_TOK_CTX_AP_REQ, input_token->length, 1))) { mech_used = gss_mech_krb5; } else if ((code == G_WRONG_MECH) && - !(code = g_verify_token_header((gss_OID) gss_mech_krb5_old, + !(code = g_verify_token_header(gss_mech_krb5_old, &(ap_req.length), &ptr, KG_TOK_CTX_AP_REQ, input_token->length, 1))) { @@ -814,7 +814,7 @@ krb5_gss_accept_sec_context(minor_status, context_handle, ctx->gss_flags |= GSS_C_PROT_READY_FLAG; ctx->established = 1; - token.length = g_token_size((gss_OID) mech_used, ap_rep.length); + token.length = g_token_size(mech_used, ap_rep.length); if ((token.value = (unsigned char *) xmalloc(token.length)) == NULL) { @@ -823,7 +823,7 @@ krb5_gss_accept_sec_context(minor_status, context_handle, goto fail; } ptr3 = token.value; - g_make_token_header((gss_OID) mech_used, ap_rep.length, + g_make_token_header(mech_used, ap_rep.length, &ptr3, KG_TOK_CTX_AP_REP); TWRITE_STR(ptr3, ap_rep.data, ap_rep.length); @@ -972,7 +972,7 @@ krb5_gss_accept_sec_context(minor_status, context_handle, tmsglen = scratch.length; toktype = KG_TOK_CTX_ERROR; - token.length = g_token_size((gss_OID) mech_used, tmsglen); + token.length = g_token_size(mech_used, tmsglen); token.value = (unsigned char *) xmalloc(token.length); if (!token.value) { krb5_free_context(context); @@ -980,7 +980,7 @@ krb5_gss_accept_sec_context(minor_status, context_handle, } ptr = token.value; - g_make_token_header((gss_OID) mech_used, tmsglen, &ptr, toktype); + g_make_token_header(mech_used, tmsglen, &ptr, toktype); TWRITE_STR(ptr, scratch.data, scratch.length); krb5_free_data_contents(context, &scratch); diff --git a/src/lib/gssapi/krb5/acquire_cred.c b/src/lib/gssapi/krb5/acquire_cred.c index a321505fd..58d3bdcab 100644 --- a/src/lib/gssapi/krb5/acquire_cred.c +++ b/src/lib/gssapi/krb5/acquire_cred.c @@ -609,11 +609,11 @@ krb5_gss_acquire_cred(minor_status, desired_name, time_req, &ret_mechs)) || (cred->prerfc_mech && GSS_ERROR(ret = generic_gss_add_oid_set_member(minor_status, - (gss_OID) gss_mech_krb5_old, + gss_mech_krb5_old, &ret_mechs))) || (cred->rfc_mech && GSS_ERROR(ret = generic_gss_add_oid_set_member(minor_status, - (gss_OID) gss_mech_krb5, + gss_mech_krb5, &ret_mechs)))) { if (cred->ccache) (void)krb5_cc_close(context, cred->ccache); diff --git a/src/lib/gssapi/krb5/init_sec_context.c b/src/lib/gssapi/krb5/init_sec_context.c index 9f70da032..91d81fb44 100644 --- a/src/lib/gssapi/krb5/init_sec_context.c +++ b/src/lib/gssapi/krb5/init_sec_context.c @@ -325,7 +325,7 @@ make_ap_req_v1(context, ctx, cred, k_cred, chan_bindings, mech_type, token) ptr = t; - g_make_token_header((gss_OID) mech_type, ap_req.length, + g_make_token_header(mech_type, ap_req.length, &ptr, KG_TOK_CTX_AP_REQ); TWRITE_STR(ptr, (unsigned char *) ap_req.data, ap_req.length); @@ -720,7 +720,7 @@ mutual_auth( ptr = (unsigned char *) input_token->value; - if (g_verify_token_header((gss_OID) ctx->mech_used, + if (g_verify_token_header(ctx->mech_used, &(ap_rep.length), &ptr, KG_TOK_CTX_AP_REP, input_token->length, 1)) { diff --git a/src/lib/gssapi/krb5/inq_cred.c b/src/lib/gssapi/krb5/inq_cred.c index 780e79870..591a655c8 100644 --- a/src/lib/gssapi/krb5/inq_cred.c +++ b/src/lib/gssapi/krb5/inq_cred.c @@ -158,11 +158,11 @@ krb5_gss_inquire_cred(minor_status, cred_handle, name, lifetime_ret, &mechs)) || (cred->prerfc_mech && GSS_ERROR(ret = generic_gss_add_oid_set_member(minor_status, - (gss_OID) gss_mech_krb5_old, + gss_mech_krb5_old, &mechs))) || (cred->rfc_mech && GSS_ERROR(ret = generic_gss_add_oid_set_member(minor_status, - (gss_OID) gss_mech_krb5, + gss_mech_krb5, &mechs)))) { k5_mutex_unlock(&cred->lock); if (ret_name) diff --git a/src/lib/gssapi/krb5/inq_names.c b/src/lib/gssapi/krb5/inq_names.c index 430132d74..c9e3dc9ad 100644 --- a/src/lib/gssapi/krb5/inq_names.c +++ b/src/lib/gssapi/krb5/inq_names.c @@ -53,38 +53,38 @@ krb5_gss_inquire_names_for_mech(minor_status, mechanism, name_types) if (major == GSS_S_COMPLETE) { /* Now add our members. */ if ( - ((major = gss_add_oid_set_member(minor_status, - (gss_OID) gss_nt_user_name, - name_types) + ((major = generic_gss_add_oid_set_member(minor_status, + gss_nt_user_name, + name_types) ) == GSS_S_COMPLETE) && - ((major = gss_add_oid_set_member(minor_status, - (gss_OID) gss_nt_machine_uid_name, - name_types) + ((major = generic_gss_add_oid_set_member(minor_status, + gss_nt_machine_uid_name, + name_types) ) == GSS_S_COMPLETE) && - ((major = gss_add_oid_set_member(minor_status, - (gss_OID) gss_nt_string_uid_name, - name_types) + ((major = generic_gss_add_oid_set_member(minor_status, + gss_nt_string_uid_name, + name_types) ) == GSS_S_COMPLETE) && - ((major = gss_add_oid_set_member(minor_status, - (gss_OID) gss_nt_service_name, - name_types) + ((major = generic_gss_add_oid_set_member(minor_status, + gss_nt_service_name, + name_types) ) == GSS_S_COMPLETE) && - ((major = gss_add_oid_set_member(minor_status, - (gss_OID) gss_nt_service_name_v2, - name_types) + ((major = generic_gss_add_oid_set_member(minor_status, + gss_nt_service_name_v2, + name_types) ) == GSS_S_COMPLETE) && - ((major = gss_add_oid_set_member(minor_status, - (gss_OID) gss_nt_exported_name, - name_types) + ((major = generic_gss_add_oid_set_member(minor_status, + gss_nt_exported_name, + name_types) ) == GSS_S_COMPLETE) && - ((major = gss_add_oid_set_member(minor_status, - (gss_OID) gss_nt_krb5_name, - name_types) + ((major = generic_gss_add_oid_set_member(minor_status, + gss_nt_krb5_name, + name_types) ) == GSS_S_COMPLETE) ) { - major = gss_add_oid_set_member(minor_status, - (gss_OID) gss_nt_krb5_principal, - name_types); + major = generic_gss_add_oid_set_member(minor_status, + gss_nt_krb5_principal, + name_types); } /* diff --git a/src/lib/gssapi/krb5/k5seal.c b/src/lib/gssapi/krb5/k5seal.c index 68aa6696c..7a904d065 100644 --- a/src/lib/gssapi/krb5/k5seal.c +++ b/src/lib/gssapi/krb5/k5seal.c @@ -117,7 +117,7 @@ make_seal_token_v1 (krb5_context context, /*** fill in the token */ ptr = t; - g_make_token_header((gss_OID) oid, 14+cksum_size+tmsglen, &ptr, toktype); + g_make_token_header(oid, 14+cksum_size+tmsglen, &ptr, toktype); /* 0..1 SIGN_ALG */ ptr[0] = signalg & 0xff; diff --git a/src/lib/gssapi/krb5/k5unseal.c b/src/lib/gssapi/krb5/k5unseal.c index 553f18b5e..30845bd85 100644 --- a/src/lib/gssapi/krb5/k5unseal.c +++ b/src/lib/gssapi/krb5/k5unseal.c @@ -527,7 +527,7 @@ kg_unseal(minor_status, context_handle, input_token_buffer, } else toktype2 = toktype; - err = g_verify_token_header((gss_OID) ctx->mech_used, + err = g_verify_token_header(ctx->mech_used, &bodysize, &ptr, toktype2, input_token_buffer->length, !ctx->proto); diff --git a/src/lib/gssapi/krb5/wrap_size_limit.c b/src/lib/gssapi/krb5/wrap_size_limit.c index 460070637..b875a965a 100644 --- a/src/lib/gssapi/krb5/wrap_size_limit.c +++ b/src/lib/gssapi/krb5/wrap_size_limit.c @@ -145,7 +145,7 @@ krb5_gss_wrap_size_limit(minor_status, context_handle, conf_req_flag, data_size = req_output_size; conflen = kg_confounder_size(ctx->k5_context, ctx->enc); data_size = (conflen + data_size + 8) & (~(OM_uint32)7); - ohlen = g_token_size((gss_OID) ctx->mech_used, + ohlen = g_token_size(ctx->mech_used, (unsigned int) (data_size + ctx->cksum_size + 14)) - req_output_size;