krb5 commit: Make gss_ctx_id_t truly opaque

Greg Hudson ghudson at MIT.EDU
Fri Aug 3 16:08:38 EDT 2012


https://github.com/krb5/krb5/commit/0b524beab7e3601bd38d6af8777a16c3c98d807c
commit 0b524beab7e3601bd38d6af8777a16c3c98d807c
Author: Simo Sorce <simo at redhat.com>
Date:   Wed May 9 14:50:35 2012 -0400

    Make gss_ctx_id_t truly opaque
    
    This allows us to still use it for type safety in the APIs while at
    the same time prevent code from trying to dereference internal_ctx_id
    by mistake.

 src/lib/gssapi/mechglue/g_imp_sec_context.c  |    2 +-
 src/lib/gssapi/mechglue/g_init_sec_context.c |    2 +-
 src/lib/gssapi/mechglue/g_unwrap_aead.c      |    2 +-
 src/lib/gssapi/mechglue/g_wrap_aead.c        |    2 +-
 src/lib/gssapi/mechglue/mglueP.h             |    4 ++--
 5 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/lib/gssapi/mechglue/g_imp_sec_context.c b/src/lib/gssapi/mechglue/g_imp_sec_context.c
index 7679c92..45ba9d6 100644
--- a/src/lib/gssapi/mechglue/g_imp_sec_context.c
+++ b/src/lib/gssapi/mechglue/g_imp_sec_context.c
@@ -148,7 +148,7 @@ gss_ctx_id_t *		context_handle;
 
     if (status == GSS_S_COMPLETE) {
 	ctx->loopback = ctx;
-	*context_handle = ctx;
+	*context_handle = (gss_ctx_id_t)ctx;
 	return (GSS_S_COMPLETE);
     }
     map_error(minor_status, mech);
diff --git a/src/lib/gssapi/mechglue/g_init_sec_context.c b/src/lib/gssapi/mechglue/g_init_sec_context.c
index 21bc345..5afea2d 100644
--- a/src/lib/gssapi/mechglue/g_init_sec_context.c
+++ b/src/lib/gssapi/mechglue/g_init_sec_context.c
@@ -194,7 +194,7 @@ OM_uint32 *		time_rec;
 	/* copy the supplied context handle */
 	union_ctx_id->internal_ctx_id = GSS_C_NO_CONTEXT;
     } else
-	union_ctx_id = *context_handle;
+	union_ctx_id = (gss_union_ctx_id_t)*context_handle;
 
     /*
      * get the appropriate cred handle from the union cred struct.
diff --git a/src/lib/gssapi/mechglue/g_unwrap_aead.c b/src/lib/gssapi/mechglue/g_unwrap_aead.c
index 8be6d6a..e78bff2 100644
--- a/src/lib/gssapi/mechglue/g_unwrap_aead.c
+++ b/src/lib/gssapi/mechglue/g_unwrap_aead.c
@@ -191,7 +191,7 @@ gss_qop_t		*qop_state;
     if (!mech)
 	return (GSS_S_BAD_MECH);
 
-    return gssint_unwrap_aead(mech, minor_status, context_handle,
+    return gssint_unwrap_aead(mech, minor_status, ctx,
 			      input_message_buffer, input_assoc_buffer,
 			      output_payload_buffer, conf_state, qop_state);
 }
diff --git a/src/lib/gssapi/mechglue/g_wrap_aead.c b/src/lib/gssapi/mechglue/g_wrap_aead.c
index ca1ef12..96cdf3c 100644
--- a/src/lib/gssapi/mechglue/g_wrap_aead.c
+++ b/src/lib/gssapi/mechglue/g_wrap_aead.c
@@ -260,7 +260,7 @@ gss_buffer_t		output_message_buffer;
     if (!mech)
 	return (GSS_S_BAD_MECH);
 
-    return gssint_wrap_aead(mech, minor_status, context_handle,
+    return gssint_wrap_aead(mech, minor_status, ctx,
 			    conf_req_flag, qop_req,
 			    input_assoc_buffer, input_payload_buffer,
 			    conf_state, output_message_buffer);
diff --git a/src/lib/gssapi/mechglue/mglueP.h b/src/lib/gssapi/mechglue/mglueP.h
index efbb370..9e87b39 100644
--- a/src/lib/gssapi/mechglue/mglueP.h
+++ b/src/lib/gssapi/mechglue/mglueP.h
@@ -23,8 +23,8 @@ do {								\
 /*
  * Array of context IDs typed by mechanism OID
  */
-typedef struct gss_ctx_id_struct {
-	struct gss_ctx_id_struct *loopback;
+typedef struct gss_union_ctx_id_struct {
+	struct gss_union_ctx_id_struct *loopback;
 	gss_OID			mech_type;
 	gss_ctx_id_t		internal_ctx_id;
 } gss_union_ctx_id_desc, *gss_union_ctx_id_t;


More information about the cvs-krb5 mailing list