]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Clean up k5buf_to_gss helper
authorGreg Hudson <ghudson@mit.edu>
Thu, 23 Aug 2012 16:58:29 +0000 (12:58 -0400)
committerGreg Hudson <ghudson@mit.edu>
Thu, 23 Aug 2012 16:59:00 +0000 (12:59 -0400)
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
src/lib/gssapi/generic/oid_ops.c

index 3fb0c762277ff04d438f15cd20313fa07d59f09b..63b7bf4da69c4eb56e44a4f9387d054580c3b4dc 100644 (file)
@@ -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);
index ff5096d604496513b248845fb690e6933b3c0a9f..665b5902f4b2223a85f68f7afcc69f4ab9dbf4fb 100644 (file)
@@ -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);
     }