resource leak in gss_krb5_copy_ccache

Morten Sylvest Olsen mso at
Wed Sep 9 06:49:23 EDT 2009

Greg Hudson wrote:
> On Tue, 2009-09-08 at 07:11 -0400, Morten Sylvest Olsen wrote:
>> I keep getting valgrind leaks reported when I use gss_krb5_copy_ccache. 
>> Looking at the code, it seems there is a krb5_free_cred_contents 
>> missing. Or I may be completely off the mark?
> I believe you are correct.  Can you please test out the attached patch
> and see if it closes the memory leaks you're seeing without causing
> other issues?

That seemed to do the trick. Our normal build environment is rhel 5.3, 
which provides mit krb5 1.6.1. The gssapi code is basically the same as 
in 1.7, I tried your fix in both, and it fixes the leak without ill 

Saw another leak in 1.7, though I didn't investigate it further:

==4937== 184 bytes in 8 blocks are definitely lost in loss record 126 of 185
==4937==    at 0x40053C0: malloc (vg_replace_malloc.c:149)
==4937==    by 0x4E46DF: strdup (in /lib/
==4937==    by 0x52B726: gaih_inet (in /lib/
==4937==    by 0x52D9F2: getaddrinfo (in /lib/
==4937==    by 0x5813BC6: krb5int_getaddrinfo (fake-addrinfo.c:315)
==4937==    by 0x552817E: krb5_sname_to_principal (sn2princ.c:112)
==4937==    by 0x57BC963: krb5_gss_import_name (import_name.c:99)
==4937==    by 0x57B18EB: gssint_import_internal_name (g_glue.c:306)
==4937==    by 0x57AF8BA: gss_add_cred (g_acquire_cred.c:383)
==4937==    by 0x57AFBC9: gss_acquire_cred (g_acquire_cred.c:198)
==4937==    by 0x797CCCA: (within /usr/lib/sasl2/
==4937==    by 0x33CD4F5: sasl_server_step (in /usr/lib/

Morten Sylvest Olsen, System Developer
Medical Insight A/S, Krumtappen 4,,2500 Valby, Denmark
Phone:+4546550444, Mobile:+4551573092,Mail: mso at

More information about the krbdev mailing list