Skip to content

Commit

Permalink
krb5: fix memory leaks from client context and cache
Browse files Browse the repository at this point in the history
Reported by EOS .
  • Loading branch information
gganis committed Mar 3, 2017
1 parent cba5c5e commit cd49a00
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/XrdSeckrb5/XrdSecProtocolkrb5.cc
Expand Up @@ -204,6 +204,8 @@ void XrdSecProtocolkrb5::Delete()
if (Ticket) krb5_free_ticket(krb_context, Ticket);
if (AuthContext) krb5_auth_con_free(krb_context, AuthContext);
if (AuthClientContext) krb5_auth_con_free(krb_client_context, AuthClientContext);
krb5_cc_close(krb_client_context, krb_client_ccache);
krb5_free_context(krb_client_context);
if (Entity.host) free(Entity.host);
if (Service) free(Service);
delete this;
Expand Down Expand Up @@ -674,7 +676,7 @@ int XrdSecProtocolkrb5::get_krbCreds(char *KP, krb5_creds **krb_creds)

// Clear my credentials
//
memset((char *)&mycreds, 0, sizeof(mycreds));
memset((char *)&mycreds, 0, sizeof(mycreds));

// Setup the "principal/instance@realm"
//
Expand All @@ -687,14 +689,16 @@ int XrdSecProtocolkrb5::get_krbCreds(char *KP, krb5_creds **krb_creds)
//
if ((rc = krb5_copy_principal(krb_client_context, the_principal, &mycreds.server)))
{CLDBG("get_krbCreds: err copying principal to creds; " <<krb_etxt(rc));
krb5_free_principal(krb_client_context, the_principal);
return rc;
}
krb5_free_principal(krb_client_context, the_principal);

// Get our principal name
//
if ((rc = krb5_cc_get_principal(krb_client_context, krb_client_ccache, &mycreds.client)))
{krb5_free_cred_contents(krb_client_context, &mycreds);
CLDBG("get_krbCreds: err copying client name to creds; " <<krb_etxt(rc));
{CLDBG("get_krbCreds: err copying client name to creds; " <<krb_etxt(rc));
krb5_free_cred_contents(krb_client_context, &mycreds);
return rc;
}

Expand Down

0 comments on commit cd49a00

Please sign in to comment.