From: Greg Hudson Date: Tue, 28 Jun 2016 16:28:11 +0000 (-0400) Subject: Fix leak in gss_display_name() for non-MN names X-Git-Tag: krb5-1.15-beta1~111 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=20fcbf2cb820df0d31e66bb11f64fb50a31008f5;p=thirdparty%2Fkrb5.git Fix leak in gss_display_name() for non-MN names RFC 2744 states that the gss_display_name() output_name_type result is "a pointer into static storage, and should be treated as read-only by the caller (in particular, the application should not attempt to free it)". For non-mechanism names, we were making a copy of the name type from the union name structure, causing a memory leak; stop doing that. ticket: 8439 (new) target_version: 1.14-next target_version: 1.13-next tags: pullup --- diff --git a/src/lib/gssapi/mechglue/g_dsp_name.c b/src/lib/gssapi/mechglue/g_dsp_name.c index 825bf4d58b..21867c814e 100644 --- a/src/lib/gssapi/mechglue/g_dsp_name.c +++ b/src/lib/gssapi/mechglue/g_dsp_name.c @@ -102,36 +102,17 @@ gss_OID * output_name_type; output_name_type)); } - /* - * copy the value of the external_name component of the union - * name into the output_name_buffer and point the output_name_type - * to the name_type component of union_name - */ - if (output_name_type != NULL && - union_name->name_type != GSS_C_NULL_OID) { - major_status = generic_gss_copy_oid(minor_status, - union_name->name_type, - output_name_type); - if (major_status != GSS_S_COMPLETE) { - map_errcode(minor_status); - return (major_status); - } - } - if ((output_name_buffer->value = - gssalloc_malloc(union_name->external_name->length + 1)) == NULL) { - if (output_name_type && *output_name_type != GSS_C_NULL_OID) { - (void) generic_gss_release_oid(minor_status, - output_name_type); - *output_name_type = NULL; - } + gssalloc_malloc(union_name->external_name->length + 1)) == NULL) return (GSS_S_FAILURE); - } output_name_buffer->length = union_name->external_name->length; (void) memcpy(output_name_buffer->value, union_name->external_name->value, union_name->external_name->length); ((char *)output_name_buffer->value)[output_name_buffer->length] = '\0'; + if (output_name_type != NULL) + *output_name_type = union_name->name_type; + return(GSS_S_COMPLETE); }