[473] in Kerberos-V5-bugs
Where does allocated memory go?
daemon@ATHENA.MIT.EDU (georges rahbani)
Wed May 18 18:06:03 1994
Date: Wed, 18 May 1994 15:04:36 -0700
To: krb5-bugs@MIT.EDU
From: georgesr@wrq.com (georges rahbani)
In the following function "krb5_get_credentials" we do a call first to
retrieve the credentials from the ccache. retrieve do allocate new memory
for the credential componentents. What happens to the already allocated
memory. It seems to get lost. In the case where this function calls the
get_cred_from_kdc the same thing happens. What am I missing? Many questions
I would like to ask:
1. Is this the appropriate place to ask these questions?
2. If yes, Where do the previous server and client structure that hang from
creds get deallocated? How about the authorization array and the host
address array?
3. I am going through the Kerberos code line by line and porting it to the
PC. I may encounter many such questions, would you like to know about them?
Thank you for your help.
Function follows:
krb5_error_code
krb5_get_credentials(options, ccache, creds)
const krb5_flags options;
krb5_ccache ccache;
krb5_creds *creds;
{
krb5_error_code retval, rv2;
krb5_creds **tgts;
krb5_creds mcreds;
krb5_flags fields;
if (!creds || !creds->server || !creds->client)
return -EINVAL;
memset((char *)&mcreds, 0, sizeof(mcreds));
mcreds.server = creds->server;
mcreds.client = creds->client;
mcreds.times.endtime = creds->times.endtime;
mcreds.keyblock = creds->keyblock;
mcreds.authdata = creds->authdata;
fields = KRB5_TC_MATCH_TIMES /*XXX |KRB5_TC_MATCH_SKEY_TYPE */
| KRB5_TC_MATCH_AUTHDATA;
if (options & KRB5_GC_USER_USER) {
/* also match on identical 2nd tkt and tkt encrypted in a
session key */
fields |= KRB5_TC_MATCH_2ND_TKT|KRB5_TC_MATCH_IS_SKEY;
mcreds.is_skey = TRUE;
mcreds.second_ticket = creds->second_ticket;
if (!creds->second_ticket.length)
return KRB5_NO_2ND_TKT;
}
retval = krb5_cc_retrieve_cred(ccache, fields, &mcreds, creds);
if (retval != KRB5_CC_NOTFOUND || options & KRB5_GC_CACHED)
return retval;
retval = krb5_get_cred_from_kdc(ccache, creds, &tgts);
if (tgts) {
register int i = 0;
while (tgts[i]) {
if (rv2 = krb5_cc_store_cred(ccache, tgts[i])) {
retval = rv2;
break;
}
i++;
}
krb5_free_tgt_creds(tgts);
}
if (!retval)
retval = krb5_cc_store_cred(ccache, creds);
return retval;
}
Georges Rahbani
Walker, Richer & Quinn, Inc.
georgesr@wrq.com