From 5e3fcaae24e89348376a7a68593933e7f8b32715 Mon Sep 17 00:00:00 2001 From: Tom Yu Date: Fri, 6 Oct 2006 21:43:02 +0000 Subject: [PATCH] * src/lib/krb5/ccache/t_cccursor.c: Bugfixes from Ezra to clean up memory leaks. ticket: 4389 status: open git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@18654 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/krb5/ccache/t_cccursor.c | 33 +++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/src/lib/krb5/ccache/t_cccursor.c b/src/lib/krb5/ccache/t_cccursor.c index 8939c6a60..68e615329 100644 --- a/src/lib/krb5/ccache/t_cccursor.c +++ b/src/lib/krb5/ccache/t_cccursor.c @@ -83,6 +83,9 @@ struct chklist chklist2[] = { krb5_error_code cr_cache(krb5_context, const char *, const char *); +krb5_error_code +dest_cache(krb5_context, const char *, const char *); + krb5_error_code do_chk(krb5_context, struct chklist *, int nmax, int *); @@ -108,7 +111,7 @@ cr_cache(krb5_context context, const char *ccname, const char *pname) goto errout; printf("created cache %s with principal %s\n", ccname, pname); } else - printf("created cache %s (uninitialized)\n"); + printf("created cache %s (uninitialized)\n", ccname); errout: if (princ != NULL) krb5_free_principal(context, princ); @@ -117,6 +120,28 @@ errout: return ret; } +krb5_error_code +dest_cache(krb5_context context, const char *ccname, const char *pname) +{ + krb5_error_code ret; + krb5_ccache ccache = NULL; + + ret = krb5_cc_resolve(context, ccname, &ccache); + if (ret) + goto errout; + if (pname != NULL) { + ret = krb5_cc_destroy(context, ccache); + if (ret) + return ret; + printf("Destroyed cache %s\n", ccname); + } else { + printf("Closed cache %s (uninitialized)\n", ccname); + ret = krb5_cc_close(context, ccache); + } +errout: + return ret; +} + int do_chk_one(const char *prefix, const char *name, struct chklist *chk) { @@ -224,7 +249,13 @@ main(int argc, char *argv[]) if (ret) goto errout; + for (i = 0; i < NCRLIST; i++) { + ret = dest_cache(context, crlist[i].ccname, crlist[i].pname); + if (ret) goto errout; + } + errout: + krb5_free_context(context); if (ret) { com_err("main", ret, ""); exit(1); -- 2.26.2