typedef struct _krb5_lcc_cursor {
PKERB_QUERY_TKT_CACHE_RESPONSE response;
int index;
+ PKERB_EXTERNAL_TICKET mstgt;
} krb5_lcc_cursor;
krb5_lcc_data *data = (krb5_lcc_data *)id->data;
KERB_EXTERNAL_TICKET *msticket;
+ lcursor = (krb5_lcc_cursor *) malloc(sizeof(krb5_lcc_cursor));
+ if (lcursor == NULL) {
+ *cursor = 0;
+ return KRB5_CC_NOMEM;
+ }
+
/*
* obtain a tgt to refresh the ccache in case the ticket is expired
*/
- if (GetMSTGT(data->LogonHandle, data->PackageId, &msticket)) {
- LsaFreeReturnBuffer(msticket);
+ if (!GetMSTGT(data->LogonHandle, data->PackageId, &lcursor->mstgt)) {
+ free(lcursor);
+ *cursor = 0;
+ KRB5_FCC_INTERNAL;
}
- lcursor = (krb5_lcc_cursor *) malloc(sizeof(krb5_lcc_cursor));
- if (lcursor == NULL)
- return KRB5_CC_NOMEM;
-
if ( !GetQueryTktCacheResponse(data->LogonHandle, data->PackageId, &lcursor->response) ) {
+ LsaFreeReturnBuffer(lcursor->mstgt);
free(lcursor);
+ *cursor = 0;
KRB5_FCC_INTERNAL;
}
lcursor->index = 0;
*cursor = (krb5_cc_cursor) lcursor;
-
return KRB5_OK;
}
{
krb5_lcc_cursor *lcursor = (krb5_lcc_cursor *) *cursor;
krb5_lcc_data *data = (krb5_lcc_data *)id->data;
- KERB_EXTERNAL_TICKET *msticket, * mstgt;
+ KERB_EXTERNAL_TICKET *msticket;
next_cred:
if ( lcursor->index >= lcursor->response->CountOfTickets )
return KRB5_CC_END;
if (!GetMSCacheTicketFromCacheInfo(data->LogonHandle, data->PackageId,
- &lcursor->response->Tickets[lcursor->index++],&msticket))
+ &lcursor->response->Tickets[lcursor->index++],&msticket)) {
+ LsaFreeReturnBuffer(lcursor->mstgt);
+ LsaFreeReturnBuffer(lcursor->response);
+ free(*cursor);
+ *cursor = 0;
return KRB5_FCC_INTERNAL;
+ }
/* Don't return tickets with NULL Session Keys */
if ( msticket->SessionKey.KeyType == KERB_ETYPE_NULL) {
}
/* convert the ticket */
- if (GetMSTGT(data->LogonHandle, data->PackageId, &mstgt)) {
- MSCredToMITCred(msticket, mstgt->DomainName, context, creds);
- LsaFreeReturnBuffer(mstgt);
- LsaFreeReturnBuffer(msticket);
- return KRB5_OK;
- } else {
- LsaFreeReturnBuffer(msticket);
- return KRB5_FCC_INTERNAL;
- }
+ MSCredToMITCred(msticket, lcursor->mstgt->DomainName, context, creds);
+ LsaFreeReturnBuffer(msticket);
+ return KRB5_OK;
}
/*
{
krb5_lcc_cursor *lcursor = (krb5_lcc_cursor *) *cursor;
+ LsaFreeReturnBuffer(lcursor->mstgt);
LsaFreeReturnBuffer(lcursor->response);
free(*cursor);
+ *cursor = 0;
return KRB5_OK;
}