From: Tom Yu Date: Thu, 22 Sep 2005 16:44:20 +0000 (+0000) Subject: fix krb5_mk_rep subkey leaks X-Git-Tag: ms-bug-test-20060525~138 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=c02a7929608e666491eb85646a5631e2b98a5ec4;p=krb5.git fix krb5_mk_rep subkey leaks * mk_req_ext.c (krb5int_generate_and_save_subkey): Check for and free pre-existing subkeys before clobbering the pointers. This fixes some memory leaks. ticket: new target_version: 1.4.3 tags: pullup component: krb5-libs git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@17387 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/krb5/krb/ChangeLog b/src/lib/krb5/krb/ChangeLog index ef63af15a..82a3826e0 100644 --- a/src/lib/krb5/krb/ChangeLog +++ b/src/lib/krb5/krb/ChangeLog @@ -1,3 +1,9 @@ +2005-09-22 Tom Yu + + * mk_req_ext.c (krb5int_generate_and_save_subkey): Check for and + free pre-existing subkeys before clobbering the pointers. This + fixes some memory leaks. + 2005-08-23 Ezra Peisach * t_ser.c (ser_kcontext_test): Remove statement declaring an diff --git a/src/lib/krb5/krb/mk_req_ext.c b/src/lib/krb5/krb/mk_req_ext.c index deeb12387..9066567ba 100644 --- a/src/lib/krb5/krb/mk_req_ext.c +++ b/src/lib/krb5/krb/mk_req_ext.c @@ -90,8 +90,13 @@ krb5int_generate_and_save_subkey (krb5_context context, d.data = (char *) &rnd_data; (void) krb5_c_random_add_entropy (context, KRB5_C_RANDSOURCE_TIMING, &d); + if (auth_context->send_subkey) + krb5_free_keyblock(context, auth_context->send_subkey); if ((retval = krb5_generate_subkey(context, keyblock, &auth_context->send_subkey))) return retval; + + if (auth_context->recv_subkey) + krb5_free_keyblock(context, auth_context->recv_subkey); retval = krb5_copy_keyblock(context, auth_context->send_subkey, &auth_context->recv_subkey); if (retval) {