From c6f1ad60df83aae9c4f1400b5b3a491e9c6429ef Mon Sep 17 00:00:00 2001 From: Theodore Tso Date: Wed, 15 Jun 1994 20:36:05 +0000 Subject: [PATCH] Fix credentials memory allocation problem. Beta 4 is more anal about freeing things.... git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@3806 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/gssapi/krb5/init_sec_context.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/lib/gssapi/krb5/init_sec_context.c b/src/lib/gssapi/krb5/init_sec_context.c index a377f7f9e..ab0943e34 100644 --- a/src/lib/gssapi/krb5/init_sec_context.c +++ b/src/lib/gssapi/krb5/init_sec_context.c @@ -74,17 +74,22 @@ make_ap_req(cred, server, endtime, chan_bindings, do_mutual, subkey, flags, /* fill in the necessary fields in creds */ memset((char *) &creds, 0, sizeof(creds)); - creds.client = cred->princ; - creds.server = server; - + if (code = krb5_copy_principal(cred->princ, &creds.client)) + return code; + if (code = krb5_copy_principal(server, &creds.server)) { + krb5_free_cred_contents(&creds); + return code; + } creds.times.endtime = *endtime; /* call mk_req. subkey and ap_req need to be used or destroyed */ if (code = krb5_mk_req_extended(do_mutual?AP_OPTS_MUTUAL_REQUIRED:0, &checksum, 0, 0, subkey, cred->ccache, - &creds, &authent, &ap_req)) - return(code); + &creds, &authent, &ap_req)) { + krb5_free_cred_contents(&creds); + return(code); + } /* store the interesting stuff from creds and authent */ *endtime = creds.times.endtime; @@ -93,11 +98,6 @@ make_ap_req(cred, server, endtime, chan_bindings, do_mutual, subkey, flags, /* free stuff which was created */ - /* XXXX There's a bug in krb5 here, but I have no clue what it is. - This is a workaround. */ - if (creds.client == cred->princ) - creds.client = NULL; - krb5_free_cred_contents(&creds); /* build up the token */ -- 2.26.2