gssapi/mech: Sprinkle const and rk_UNCONST.

This commit is contained in:
Taylor R Campbell
2023-06-20 10:17:14 +00:00
committed by Nicolas Williams
parent 80545251a0
commit 34dc2dda57
33 changed files with 54 additions and 41 deletions

View File

@@ -686,7 +686,7 @@ _gss_mg_log_name(int level,
void
_gss_mg_log_cred(int level,
struct _gss_cred *cred,
const struct _gss_cred *cred,
const char *fmt, ...);

View File

@@ -334,7 +334,7 @@ _gss_mg_log_name(int level,
void
_gss_mg_log_cred(int level,
struct _gss_cred *cred,
const struct _gss_cred *cred,
const char *fmt, ...)
{
struct _gss_mechanism_cred *mc;

View File

@@ -239,7 +239,8 @@ gss_accept_sec_context(OM_uint32 *minor_status,
OM_uint32 major_status, mech_ret_flags, junk;
gssapi_mech_interface m = NULL;
struct _gss_context *ctx = (struct _gss_context *) *context_handle;
struct _gss_cred *cred = (struct _gss_cred *) acceptor_cred_handle;
const struct _gss_cred *cred =
(const struct _gss_cred *)acceptor_cred_handle;
struct _gss_mechanism_cred *mc;
gss_buffer_desc defective_token_error;
gss_const_cred_id_t acceptor_mc;

View File

@@ -145,7 +145,7 @@ gss_acquire_cred_from(OM_uint32 *minor_status,
OM_uint32 *time_rec)
{
OM_uint32 major_status, minor;
struct _gss_name *name = (struct _gss_name *)desired_name;
struct _gss_name *name = rk_UNCONST(desired_name);
gssapi_mech_interface m;
struct _gss_cred *cred = NULL;
size_t i;

View File

@@ -119,7 +119,7 @@ add_mech_cred_internal(OM_uint32 *minor_status,
if (desired_name != GSS_C_NO_NAME) {
major_status = _gss_find_mn(minor_status,
(struct _gss_name *)desired_name,
rk_UNCONST(desired_name),
&m->gm_mech_oid, &mn);
if (major_status != GSS_S_COMPLETE)
return major_status;

View File

@@ -85,7 +85,7 @@ attr_authorize_localname(OM_uint32 *minor_status,
int authenticated = 0, complete = 0;
tmpMajor = gss_get_name_attribute(minor_status,
(gss_name_t)name,
rk_UNCONST(name),
GSS_C_ATTR_LOCAL_LOGIN_USER,
&authenticated,
&complete,
@@ -171,7 +171,7 @@ gss_userok(gss_const_name_t name,
gss_buffer_desc userBuf;
gss_name_t userName;
userBuf.value = (void *)user;
userBuf.value = rk_UNCONST(user);
userBuf.length = strlen(user);
major_status = gss_import_name(&minor_status, &userBuf,

View File

@@ -61,7 +61,7 @@ gss_canonicalize_name(OM_uint32 *minor_status,
gss_name_t *output_name)
{
OM_uint32 major_status;
struct _gss_name *name = (struct _gss_name *) input_name;
struct _gss_name *name = rk_UNCONST(input_name);
struct _gss_mechanism_name *mn;
gssapi_mech_interface m;
gss_name_t new_canonical_name;

View File

@@ -36,8 +36,8 @@ gss_compare_name(OM_uint32 *minor_status,
gss_const_name_t name2_arg,
int *name_equal)
{
struct _gss_name *name1 = (struct _gss_name *) name1_arg;
struct _gss_name *name2 = (struct _gss_name *) name2_arg;
struct _gss_name *name1 = rk_UNCONST(name1_arg);
struct _gss_name *name2 = rk_UNCONST(name2_arg);
/*
* First check the implementation-independent name if both

View File

@@ -33,7 +33,8 @@ gss_context_time(OM_uint32 *minor_status,
gss_const_ctx_id_t context_handle,
OM_uint32 *time_rec)
{
struct _gss_context *ctx = (struct _gss_context *) context_handle;
const struct _gss_context *ctx =
(const struct _gss_context *)context_handle;
gssapi_mech_interface m = ctx->gc_mech;
return (m->gm_context_time(minor_status, ctx->gc_ctx, time_rec));

View File

@@ -35,7 +35,7 @@ gss_display_name(OM_uint32 *minor_status,
gss_OID *output_name_type)
{
OM_uint32 major_status;
struct _gss_name *name = (struct _gss_name *) input_name;
struct _gss_name *name = rk_UNCONST(input_name);
struct _gss_mechanism_name *mn;
_mg_buffer_zero(output_name_buffer);

View File

@@ -109,7 +109,7 @@ gss_duplicate_cred(OM_uint32 *minor_status,
{
struct _gss_mechanism_cred *mc;
struct _gss_cred *new_cred;
struct _gss_cred *cred = (struct _gss_cred *)input_cred_handle;
const struct _gss_cred *cred = (const struct _gss_cred *)input_cred_handle;
OM_uint32 major_status, junk;
if (input_cred_handle == GSS_C_NO_CREDENTIAL) {

View File

@@ -34,7 +34,7 @@ gss_duplicate_name(OM_uint32 *minor_status,
gss_name_t *dest_name)
{
OM_uint32 major_status;
struct _gss_name *name = (struct _gss_name *) src_name;
struct _gss_name *name = rk_UNCONST(src_name);
struct _gss_name *new_name;
struct _gss_mechanism_name *mn;

View File

@@ -49,7 +49,7 @@ gss_export_name(OM_uint32 *minor_status,
gss_const_name_t input_name,
gss_buffer_t exported_name)
{
struct _gss_name *name = (struct _gss_name *) input_name;
const struct _gss_name *name = (const struct _gss_name *)input_name;
struct _gss_mechanism_name *mn;
_mg_buffer_zero(exported_name);

View File

@@ -35,7 +35,8 @@ gss_get_mic(OM_uint32 *minor_status,
const gss_buffer_t message_buffer,
gss_buffer_t message_token)
{
struct _gss_context *ctx = (struct _gss_context *) context_handle;
const struct _gss_context *ctx =
(const struct _gss_context *)context_handle;
gssapi_mech_interface m;
_mg_buffer_zero(message_token);

View File

@@ -37,7 +37,7 @@ gss_get_neg_mechs(OM_uint32 *minor_status,
gss_const_cred_id_t cred_handle,
gss_OID_set *mechs)
{
struct _gss_cred *cred = (struct _gss_cred *)cred_handle;
const struct _gss_cred *cred = (const struct _gss_cred *)cred_handle;
if (minor_status == NULL)
return GSS_S_CALL_INACCESSIBLE_WRITE;

View File

@@ -35,7 +35,7 @@ _gss_mg_find_mech_cred(
gss_const_cred_id_t cred_handle,
gss_const_OID mech_type)
{
struct _gss_cred *cred = (struct _gss_cred *)cred_handle;
const struct _gss_cred *cred = (const struct _gss_cred *)cred_handle;
struct _gss_mechanism_cred *mc;
if (cred == NULL)
@@ -52,7 +52,7 @@ static void
log_init_sec_context(struct _gss_context *ctx,
struct _gss_name *target,
OM_uint32 req_flags,
struct _gss_cred *cred,
const struct _gss_cred *cred,
gss_OID mech_type,
gss_buffer_t input_token)
{
@@ -159,7 +159,7 @@ gss_init_sec_context(OM_uint32 * minor_status,
OM_uint32 major_status;
gssapi_mech_interface m;
gss_const_name_t mn_inner = GSS_C_NO_NAME;
struct _gss_name *name = (struct _gss_name *) target_name;
struct _gss_name *name = rk_UNCONST(target_name);
struct _gss_mechanism_name *mn;
struct _gss_context *ctx = (struct _gss_context *) *context_handle;
gss_const_cred_id_t cred_handle;
@@ -183,7 +183,7 @@ gss_init_sec_context(OM_uint32 * minor_status,
if (_gss_mg_log_level(1))
log_init_sec_context(ctx, name, req_flags,
(struct _gss_cred *)initiator_cred_handle,
(const struct _gss_cred *)initiator_cred_handle,
input_mech_type, input_token);
/*

View File

@@ -40,7 +40,8 @@ gss_inquire_context(OM_uint32 *minor_status,
int *xopen)
{
OM_uint32 major_status;
struct _gss_context *ctx = (struct _gss_context *) context_handle;
const struct _gss_context *ctx =
(const struct _gss_context *)context_handle;
gssapi_mech_interface m;
struct _gss_name *name;
gss_name_t src_mn, targ_mn;

View File

@@ -52,7 +52,7 @@ gss_inquire_cred(OM_uint32 *minor_status,
{
OM_uint32 major_status;
struct _gss_mech_switch *m;
struct _gss_cred *cred = (struct _gss_cred *) cred_handle;
const struct _gss_cred *cred = (const struct _gss_cred *)cred_handle;
struct _gss_name *name;
struct _gss_mechanism_name *mn;
OM_uint32 min_lifetime;

View File

@@ -59,7 +59,8 @@ gss_inquire_cred_by_mech(OM_uint32 *minor_status,
return (GSS_S_NO_CRED);
if (cred_handle != GSS_C_NO_CREDENTIAL) {
struct _gss_cred *cred = (struct _gss_cred *) cred_handle;
const struct _gss_cred *cred =
(const struct _gss_cred *)cred_handle;
HEIM_TAILQ_FOREACH(mcp, &cred->gc_mc, gmc_link)
if (mcp->gmc_mech == m)
break;

View File

@@ -38,7 +38,7 @@ gss_inquire_cred_by_oid (OM_uint32 *minor_status,
const gss_OID desired_object,
gss_buffer_set_t *data_set)
{
struct _gss_cred *cred = (struct _gss_cred *) cred_handle;
const struct _gss_cred *cred = (const struct _gss_cred *)cred_handle;
OM_uint32 status = GSS_S_COMPLETE;
struct _gss_mechanism_cred *mc;
gssapi_mech_interface m;

View File

@@ -34,7 +34,7 @@ gss_inquire_mechs_for_name(OM_uint32 *minor_status,
gss_OID_set *mech_types)
{
OM_uint32 major_status;
struct _gss_name *name = (struct _gss_name *) input_name;
const struct _gss_name *name = (const struct _gss_name *)input_name;
struct _gss_mech_switch *m;
gss_OID_set name_types;
int present;

View File

@@ -38,7 +38,8 @@ gss_inquire_sec_context_by_oid (OM_uint32 *minor_status,
const gss_OID desired_object,
gss_buffer_set_t *data_set)
{
struct _gss_context *ctx = (struct _gss_context *) context_handle;
const struct _gss_context *ctx =
(const struct _gss_context *)context_handle;
OM_uint32 major_status;
gssapi_mech_interface m;

View File

@@ -313,6 +313,7 @@ _gss_load_mech(void)
while (fgets(buf, sizeof(buf), fp)) {
_gss_mo_init *mi;
char *gm_name = NULL;
if (*buf == '#')
continue;
@@ -355,7 +356,7 @@ _gss_load_mech(void)
m->gm_so = so;
m->gm_mech_oid = mech_oid;
m->gm_mech.gm_name = strdup(name);
m->gm_mech.gm_name = gm_name = strdup(name);
m->gm_mech.gm_mech_oid = *mech_oid;
m->gm_mech.gm_flags = 0;
m->gm_mech.gm_compat = calloc(1, sizeof(struct gss_mech_compat_desc_struct));
@@ -462,7 +463,7 @@ _gss_load_mech(void)
if (m != NULL) {
free(m->gm_mech.gm_compat);
/* do not free OID, it has been interned */
free((char *)m->gm_mech.gm_name);
free(gm_name);
free(m);
}
if (so != NULL)

View File

@@ -106,7 +106,7 @@ gss_localname(OM_uint32 *minor_status,
gss_buffer_t localname)
{
OM_uint32 major_status = GSS_S_UNAVAILABLE;
struct _gss_name *name = (struct _gss_name *) pname;
struct _gss_name *name = rk_UNCONST(pname);
struct _gss_mechanism_name *mn = NULL;
*minor_status = 0;

View File

@@ -33,7 +33,8 @@ gss_process_context_token(OM_uint32 *minor_status,
gss_const_ctx_id_t context_handle,
const gss_buffer_t token_buffer)
{
struct _gss_context *ctx = (struct _gss_context *) context_handle;
const struct _gss_context *ctx =
(const struct _gss_context *)context_handle;
gssapi_mech_interface m = ctx->gc_mech;
return (m->gm_process_context_token(minor_status, ctx->gc_ctx,

View File

@@ -88,7 +88,7 @@ gss_store_cred_into2(OM_uint32 *minor_status,
gss_cred_usage_t *cred_usage_stored,
gss_buffer_set_t *env)
{
struct _gss_cred *cred = (struct _gss_cred *)input_cred_handle;
const struct _gss_cred *cred = (const struct _gss_cred *)input_cred_handle;
struct _gss_mechanism_cred *mc;
OM_uint32 major_status;
OM_uint32 minor;

View File

@@ -36,7 +36,8 @@ gss_unwrap(OM_uint32 *minor_status,
int *conf_state,
gss_qop_t *qop_state)
{
struct _gss_context *ctx = (struct _gss_context *) context_handle;
const struct _gss_context *ctx =
(const struct _gss_context *)context_handle;
gssapi_mech_interface m;
if (conf_state)

View File

@@ -35,7 +35,8 @@ gss_verify_mic(OM_uint32 *minor_status,
const gss_buffer_t token_buffer,
gss_qop_t *qop_state)
{
struct _gss_context *ctx = (struct _gss_context *) context_handle;
const struct _gss_context *ctx =
(const struct _gss_context *)context_handle;
gssapi_mech_interface m;
if (qop_state)

View File

@@ -52,7 +52,8 @@ gss_wrap(OM_uint32 *minor_status,
int *conf_state,
gss_buffer_t output_message_buffer)
{
struct _gss_context *ctx = (struct _gss_context *) context_handle;
const struct _gss_context *ctx =
(const struct _gss_context *)context_handle;
gssapi_mech_interface m;
if (conf_state)

View File

@@ -36,7 +36,8 @@ gss_wrap_size_limit(OM_uint32 *minor_status,
OM_uint32 req_output_size,
OM_uint32 *max_input_size)
{
struct _gss_context *ctx = (struct _gss_context *) context_handle;
const struct _gss_context *ctx =
(const struct _gss_context *)context_handle;
gssapi_mech_interface m;
*max_input_size = 0;

View File

@@ -41,9 +41,9 @@ gssspi_exchange_meta_data(
{
OM_uint32 major_status, junk;
gssapi_mech_interface m;
struct _gss_name *name = (struct _gss_name *) target_name;
struct _gss_name *name = rk_UNCONST(target_name);
struct _gss_mechanism_name *mn;
struct _gss_context *ctx = (struct _gss_context *) *context_handle;
struct _gss_context *ctx = rk_UNCONST(*context_handle);
gss_cred_id_t cred_handle;
int allocated_ctx;
gss_const_OID mech_type = input_mech_type;

View File

@@ -41,9 +41,9 @@ gssspi_query_meta_data(
{
OM_uint32 major_status, junk;
gssapi_mech_interface m;
struct _gss_name *name = (struct _gss_name *) target_name;
struct _gss_name *name = rk_UNCONST(target_name);
struct _gss_mechanism_name *mn;
struct _gss_context *ctx = (struct _gss_context *) *context_handle;
struct _gss_context *ctx = rk_UNCONST(*context_handle);
gss_cred_id_t cred_handle;
int allocated_ctx;
gss_const_OID mech_type = input_mech_type;

View File

@@ -350,7 +350,8 @@ gss_inquire_sec_context_by_oid(OM_uint32 *minor_status,
const gss_OID desired_object,
gss_buffer_set_t *data_set)
{
struct test_context *ctx = (struct test_context *)context_handle;
const struct test_context *ctx =
(const struct test_context *)context_handle;
OM_uint32 major;
uint8_t keybytes[32] = { 0 };
uint8_t typebytes[4];