Re: Crash while trying to destroy memory cache with Heimdal 1.4.1rc2
Love Hörnquist Åstrand <[email protected]>
| Newsgroups | gmane.comp.encryption.kerberos.heimdal.general |
|---|---|
| Message-ID | <[email protected]> |
Hello, Think about krb5_cc_destroy as a krb5_cc_close() combined with delete all data. > Hi, > > I need some help in understanding the Heimdal KRB5 Memory cache usage. > In the file 'lib/krb5/test_cc.c ', I see the following line in documentation. > > 93 /* > 94 * Check that a closed cc still keeps it data and that it's no longer > 95 * there when it's destroyed. > 96 */ > This checks that if a credential cache doesn't go away on krb5_cc_close() and that is really gone when calling krb5_cc_destroy(). > This implies, that a KRB5 cache needs to be destroyed after it is close, or else it will retain the data. > But if you look at the code, it suggests that ref counting is done and the data is freed when you do a close. > The ref counting can be seen in the file 'lib/krb5/mcache.c ', in following lines: Reference counting is done on the name, so that multiple holders of the same cache wont destroy the underlaying handle. The credential data can be destroyed though. > So I chose to still do a krb5_cc_destroy to make sure I'm not leaking memory in some other scenarios. > But, when my class tries to do a krb5_cc_destroy() in the destructor, it hits an krb5_abortx() in the same file on following line numbers: > > 200 if (m->refcnt == 0) > 201 krb5_abortx(context, "mcc_destroy: refcnt already 0"); > 202 krb5_cc_destroy() is an implicit krb5_cc_close(). > I need some help in understanding the use of KRB5 cache of type MEMORY. Following are the specific questions I need help with: > 1] Is Krb5 Mem cache data ref-counted or needs to be explicitly destroyed? Its refcounted and the data is destroyed. > 2] While destroying the object, should I use krb5_cc_close() or krb5_cc_destroy() or both? krb5_cc_destroy(), destroy lead to the marking the object as dead, and when the last reference is dropped, its gone. It can be resurected by krb5_cc_initalize(). Love
smime.p7s
(application/pkcs7-signature, 4.3 KB) - not displayed