After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 729874 - goaidentity: don't leak default credentials cache
goaidentity: don't leak default credentials cache
Status: RESOLVED FIXED
Product: gnome-online-accounts
Classification: Core
Component: Kerberos
unspecified
Other All
: Normal normal
: ---
Assigned To: GNOME Online Accounts maintainer(s)
GNOME Online Accounts maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2014-05-09 13:14 UTC by Ray Strode [halfline]
Modified: 2014-05-09 19:11 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
goaidentity: don't leak default credentials cache (3.83 KB, patch)
2014-05-09 13:14 UTC, Ray Strode [halfline]
committed Details | Review
goaidentity: one more ccache leak (2.63 KB, patch)
2014-05-09 13:55 UTC, Ray Strode [halfline]
committed Details | Review

Description Ray Strode [halfline] 2014-05-09 13:14:30 UTC
krb5_cc_default doesn't return a shared resource, and
the results need to be freed
Comment 1 Ray Strode [halfline] 2014-05-09 13:14:31 UTC
Created attachment 276243 [details] [review]
goaidentity: don't leak default credentials cache
Comment 2 Debarshi Ray 2014-05-09 13:35:45 UTC
Review of attachment 276243 [details] [review]:

I think we are missing one hunk.

::: src/goaidentity/goakerberosidentitymanager.c
@@ -792,6 +792,1 @@
-      krb5_ccache default_cache;
-
-      error_code = krb5_cc_default (self->priv->kerberos_context, &default_cache);
... 3 more ...
+      error_code = krb5_cc_default (self->priv->kerberos_context, credentials_cache);

This is used in sign_in_identity. If error_code is 0 then it creates a new GoaKerberosIdentity. The krb5_ccache passed to goa_kerberos_identity_new is this one, and it makes a copy of it instead of stealing ownership. That means we should do krb5_cc_close irrespective whether the identity could be created or not.
Comment 3 Ray Strode [halfline] 2014-05-09 13:55:27 UTC
Created attachment 276246 [details] [review]
goaidentity: one more ccache leak

goa_kerberos_identity_new copies the passed in credential cache,
so we should clean up the original on sign-in.

Spotted by rishi.
Comment 4 Debarshi Ray 2014-05-09 14:17:48 UTC
Review of attachment 276246 [details] [review]:

Looks good. You could squash it into the previous patch because it is part of the same thing.

::: src/goaidentity/goakerberosidentitymanager.c
@@ +854,3 @@
         }
+
+        krb5_cc_close (self->priv->kerberos_context, credentials_cache);

I am beginning to wonder if it would be more readable to get rid of the else corresponding to "if (error_code != 0)" and doing the krb5_cc_close right after the goa_kerberos_identity_new. But that is just a cosmetic thing that can be done separately later.
Comment 5 Debarshi Ray 2014-05-09 14:18:41 UTC
Review of attachment 276243 [details] [review]:

This is complete in combination with the other patch.
Comment 6 Ray Strode [halfline] 2014-05-09 19:11:02 UTC
squashed and refactored like you suggested.