From be74d2e7fa486fd7e5cf59b7e845278164cfb76a Mon Sep 17 00:00:00 2001 From: Greg Hudson Date: Thu, 23 Aug 2012 12:58:29 -0400 Subject: 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(-) (limited to 'src/lib/gssapi') diff --git a/src/lib/gssapi/generic/gssapiP_generic.h b/src/lib/gssapi/generic/gssapiP_generic.h index 3fb0c76227..63b7bf4da6 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 ff5096d604..665b5902f4 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); } -- cgit