]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Free GSS checksum data deterministically 658/head
authorTomas Kuthan <tkuthan@gmail.com>
Tue, 16 May 2017 09:24:40 +0000 (11:24 +0200)
committerGreg Hudson <ghudson@mit.edu>
Wed, 24 May 2017 18:27:12 +0000 (14:27 -0400)
In the normal course of execution, md5.contents allocated by
kg_checksum_channel_bindings() in make_ap_req_v1() is freed in
make_gss_checksum().  But when there is a failure in
krb5_mk_req_extended() or in make_gss_checksum() before free is
called, the memory leaks.

This patch frees the memory unconditionally in make_ap_req_v1().

ticket: 8584 (new)
target_version: 1.15-next
target_version: 1.14-next
tags: pullup

src/lib/gssapi/krb5/init_sec_context.c

index 8e5cc37fbb78525d4ccff127d3803c1326628327..1be1b5878400ece8fa5d6a7eabad2499927bd468 100644 (file)
@@ -356,9 +356,6 @@ make_gss_checksum (krb5_context context, krb5_auth_context auth_context,
     TWRITE_STR(ptr, data->md5.contents, data->md5.length);
     TWRITE_INT(ptr, data->ctx->gss_flags, 0);
 
-    /* done with this, free it */
-    xfree(data->md5.contents);
-
     if (credmsg.data) {
         TWRITE_INT16(ptr, KRB5_GSS_FOR_CREDS_OPTION, 0);
         TWRITE_INT16(ptr, credmsg.length, 0);
@@ -430,6 +427,7 @@ make_ap_req_v1(context, ctx, cred, k_cred, ad_context,
     code = krb5_mk_req_extended(context, &ctx->auth_context, mk_req_flags,
                                 NULL, k_cred, &ap_req);
     krb5_auth_con_set_authdata_context(context, ctx->auth_context, NULL);
+    krb5_free_checksum_contents(context, &cksum_struct.md5);
     krb5_free_data_contents(context, &cksum_struct.checksum_data);
     if (code)
         goto cleanup;