krb5 commit: Clean up k5buf_to_gss helper

Greg Hudson ghudson at MIT.EDU
Thu Aug 23 12:59:30 EDT 2012


https://github.com/krb5/krb5/commit/be74d2e7fa486fd7e5cf59b7e845278164cfb76a
commit be74d2e7fa486fd7e5cf59b7e845278164cfb76a
Author: Greg Hudson <ghudson at mit.edu>
Date:   Thu Aug 23 12:58:29 2012 -0400

    Clean up k5buf_to_gss helper
    
    k5buf_to_gss was used in only one place (generic_gss_oid_to_str),
    where we want to include the terminating null byte in the GSS buffer.
    Remove that assumption from the helper, and instead explicitly append
    the null byte to the buffer before translating.

 src/lib/gssapi/generic/gssapiP_generic.h |    2 +-
 src/lib/gssapi/generic/oid_ops.c         |    6 ++----
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/src/lib/gssapi/generic/gssapiP_generic.h b/src/lib/gssapi/generic/gssapiP_generic.h
index 3fb0c76..63b7bf4 100644
--- a/src/lib/gssapi/generic/gssapiP_generic.h
+++ b/src/lib/gssapi/generic/gssapiP_generic.h
@@ -277,7 +277,7 @@ k5buf_to_gss(OM_uint32 *minor,
 {
     OM_uint32 status = GSS_S_COMPLETE;
     char *bp = krb5int_buf_data(input_k5buf);
-    output_buffer->length = krb5int_buf_len(input_k5buf)+1;
+    output_buffer->length = krb5int_buf_len(input_k5buf);
 #if defined(_WIN32) || defined(DEBUG_GSSALLOC)
     if (output_buffer->length > 0) {
         output_buffer->value = gssalloc_malloc(output_buffer->length);
diff --git a/src/lib/gssapi/generic/oid_ops.c b/src/lib/gssapi/generic/oid_ops.c
index ff5096d..665b590 100644
--- a/src/lib/gssapi/generic/oid_ops.c
+++ b/src/lib/gssapi/generic/oid_ops.c
@@ -238,7 +238,6 @@ generic_gss_oid_to_str(OM_uint32 *minor_status,
     OM_uint32           number;
     OM_uint32 i;
     unsigned char       *cp;
-    char                *bp;
     struct k5buf        buf;
 
     if (minor_status != NULL)
@@ -271,9 +270,8 @@ generic_gss_oid_to_str(OM_uint32 *minor_status,
             number = 0;
         }
     }
-    krb5int_buf_add(&buf, "}");
-    bp = krb5int_buf_data(&buf);
-    if (bp == NULL) {
+    krb5int_buf_add_len(&buf, "}\0", 2);
+    if (krb5int_buf_data(&buf) == NULL) {
         *minor_status = ENOMEM;
         return(GSS_S_FAILURE);
     }


More information about the cvs-krb5 mailing list